]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: skip target_session_attrs with libpw < 14 1022/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 10 Mar 2025 23:26:23 +0000 (00:26 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 10 Mar 2025 23:26:23 +0000 (00:26 +0100)
Only one test fails with the currently "oldest" libpq, which is 10.2,
however the docs in libpq 13 are not explicit in which modes are
supported and, afaics, 'replica' shouldn't work either.

https://www.postgresql.org/docs/13/libpq-connect.html

tests/test_connection.py
tests/test_connection_async.py

index 4e477f6f0b05971a19c38f8139d82c2ec7abb089..60d2083a13cd636e272c99b31fd75b06737685ba 100644 (file)
@@ -905,18 +905,19 @@ def test_right_exception_on_session_timeout(conn):
     assert type(ex.value) is want_ex
 
 
-# NOTE: these "tsa" tests assume that the database we use for tests is a primary.
-
-
+@pytest.mark.libpq(">= 14")
 @pytest.mark.parametrize("mode", ["any", "read-write", "primary", "prefer-standby"])
 def test_connect_tsa(conn_cls, dsn, mode):
+    # NOTE: assume that the test database is a "primary"
     params = conninfo_to_dict(dsn, target_session_attrs=mode)
     with conn_cls.connect(**params) as conn:
         assert conn.pgconn.status == pq.ConnStatus.OK
 
 
+@pytest.mark.libpq(">= 14")
 @pytest.mark.parametrize("mode", ["read-only", "standby", "nosuchmode"])
 def test_connect_tsa_bad(conn_cls, dsn, mode):
+    # NOTE: assume that the test database is a "primary"
     params = conninfo_to_dict(dsn, target_session_attrs=mode)
     with pytest.raises(psycopg.OperationalError, match=mode):
         conn_cls.connect(**params)
index 7662ea9e51788e0942dc3c945adf3d1b5dbc7760..c8da671da328e20d9a407507b4f7874c1df08ee3 100644 (file)
@@ -911,18 +911,19 @@ async def test_right_exception_on_session_timeout(aconn):
     assert type(ex.value) is want_ex
 
 
-# NOTE: these "tsa" tests assume that the database we use for tests is a primary.
-
-
+@pytest.mark.libpq(">= 14")
 @pytest.mark.parametrize("mode", ["any", "read-write", "primary", "prefer-standby"])
 async def test_connect_tsa(aconn_cls, dsn, mode):
+    # NOTE: assume that the test database is a "primary"
     params = conninfo_to_dict(dsn, target_session_attrs=mode)
     async with await aconn_cls.connect(**params) as aconn:
         assert aconn.pgconn.status == pq.ConnStatus.OK
 
 
+@pytest.mark.libpq(">= 14")
 @pytest.mark.parametrize("mode", ["read-only", "standby", "nosuchmode"])
 async def test_connect_tsa_bad(aconn_cls, dsn, mode):
+    # NOTE: assume that the test database is a "primary"
     params = conninfo_to_dict(dsn, target_session_attrs=mode)
     with pytest.raises(psycopg.OperationalError, match=mode):
         await aconn_cls.connect(**params)