]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: mark tests as failing to monitoring strange behaviour with Python 3.12
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 24 May 2023 23:09:09 +0000 (01:09 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 1 Aug 2023 02:47:43 +0000 (03:47 +0100)
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
tests/test_errors.py

index 1cfeea4aa81eaf9bd3153f5cad4305f9d82d5b37..7314f6f31a93b6e676ac485728caf1d7eaabe03d 100644 (file)
@@ -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:
index f9f33f141c6dbf0c563e645a2b9ff78656b6d203..ddf57513ce78218f2731708ffcfe6f82957e1d78 100644 (file)
@@ -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: