From: Daniele Varrazzo Date: Wed, 24 May 2023 23:09:09 +0000 (+0200) Subject: test: mark tests as failing to monitoring strange behaviour with Python 3.12 X-Git-Tag: 3.1.10~6^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b3450ddfe9fdb60f18f2e0bf0eff4a375e50089;p=thirdparty%2Fpsycopg.git test: mark tests as failing to monitoring strange behaviour with Python 3.12 With Python 3.12a7 and Cython-3.0.0b3, these two tests fails. It seems that when an exception is involved the __del__ method is not called. --- diff --git a/tests/test_connection.py b/tests/test_connection.py index 1cfeea4aa..7314f6f31 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1,3 +1,4 @@ +import sys import time import pytest import logging @@ -6,7 +7,7 @@ from typing import Any, List from dataclasses import dataclass import psycopg -from psycopg import Notify, errors as e +from psycopg import Notify, pq, errors as e from psycopg.rows import tuple_row from psycopg.conninfo import conninfo_to_dict, make_conninfo @@ -86,6 +87,12 @@ def test_cursor_closed(conn): conn.cursor() +# TODO: the INERROR started failing in the C implementation in Python 3.12a7 +# compiled with Cython-3.0.0b3, not before. +@pytest.mark.xfail( + (pq.__impl__ in ("c", "binary") and sys.version_info[:2] == (3, 12)), + reason="Something with Exceptions, C, Python 3.12", +) def test_connection_warn_close(conn_cls, dsn, recwarn): conn = conn_cls.connect(dsn) conn.close() @@ -104,9 +111,10 @@ def test_connection_warn_close(conn_cls, dsn, recwarn): conn = conn_cls.connect(dsn) try: conn.execute("select wat") - except Exception: + except psycopg.ProgrammingError: pass del conn + gc_collect() assert "INERROR" in str(recwarn.pop(ResourceWarning).message) with conn_cls.connect(dsn) as conn: diff --git a/tests/test_errors.py b/tests/test_errors.py index f9f33f141..ddf57513c 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,3 +1,4 @@ +import sys import pickle from typing import List from weakref import ref @@ -182,6 +183,10 @@ def test_diag_pickle(conn): @pytest.mark.slow +@pytest.mark.xfail( + (pq.__impl__ in ("c", "binary") and sys.version_info[:2] == (3, 12)), + reason="Something with Exceptions, C, Python 3.12", +) def test_diag_survives_cursor(conn): cur = conn.cursor() with pytest.raises(e.Error) as exc: