From 8f06a19a26f7942fbdc76a2fba62963c5d300e6a Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 25 May 2023 01:09:09 +0200 Subject: [PATCH] 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. --- tests/test_connection.py | 12 ++++++++++-- tests/test_errors.py | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) 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: -- 2.47.3