]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Skip certain tests on PG < 10
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 24 Mar 2020 11:34:11 +0000 (00:34 +1300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 24 Mar 2020 12:02:18 +0000 (01:02 +1300)
The server raises "could not determine data type" for pretty simple
queries of the form "select $1, $2, $3"

Should ask the PG devs if there is a workaround short of knowing the
oids.

tests/fix_async.py
tests/fix_db.py
tests/pq/test_exec.py
tests/test_async_cursor.py
tests/test_cursor.py

index fb7c0ac0c93e649d370e3b64cddfbb4a5223e6ee..5bd4c0b700f29dedbea022f176c8cba8ad204954 100644 (file)
@@ -10,7 +10,7 @@ def loop():
 
 
 @pytest.fixture
-def aconn(loop, dsn):
+def aconn(loop, dsn, pq):
     """Return an `AsyncConnection` connected to the ``--test-dsn`` database."""
     from psycopg3 import AsyncConnection
 
index 843c29540d8285abe84376663f4bc50165989488..140fa9d13a6ae09ad4f133f50d1151a7597fea10 100644 (file)
@@ -99,7 +99,12 @@ def dsn(request):
 @pytest.fixture
 def pgconn(pq, dsn):
     """Return a PGconn connection open to `--test-dsn`."""
-    return pq.PGconn.connect(dsn.encode("utf8"))
+    conn = pq.PGconn.connect(dsn.encode("utf8"))
+    if conn.status != 0:
+        pytest.fail(
+            f"bad connection: {conn.error_message.decode('utf8', 'replace')}"
+        )
+    return conn
 
 
 @pytest.fixture
index e991d753c3cb413a26d28fb0d60a57b772f042ea..e7579d71b1f809d4411c2271ad7fb97c8af1015d 100644 (file)
@@ -38,6 +38,8 @@ def test_exec_params_types(pq, pgconn):
 
 
 def test_exec_params_nulls(pq, pgconn):
+    if pgconn.server_version < 100000:
+        pytest.xfail("it doesn't work on pg < 10")
     res = pgconn.exec_params(b"select $1, $2, $3", [b"hi", b"", None])
     assert res.status == pq.ExecStatus.TUPLES_OK
     assert res.get_value(0, 0) == b"hi"
index 4c0dfd57caf5d8f01029b0763474879fb6739ed0..4c9e0e587a85c54f5a20e6eb2d3fb84fa64c1714 100644 (file)
@@ -1,3 +1,6 @@
+import pytest
+
+
 def test_execute_many(aconn, loop):
     cur = aconn.cursor()
     rv = loop.run_until_complete(cur.execute("select 'foo'; select 'bar'"))
@@ -10,6 +13,8 @@ def test_execute_many(aconn, loop):
 
 
 def test_execute_sequence(aconn, loop):
+    if aconn.pgconn.server_version < 100000:
+        pytest.xfail("it doesn't work on pg < 10")
     cur = aconn.cursor()
     rv = loop.run_until_complete(
         cur.execute("select %s, %s, %s", [1, "foo", None])
index 52fc3f8172f9124a1016278c055cdf8c2525c084..658153ff9530e7af65b099dab6895c4ee0d401d2 100644 (file)
@@ -1,3 +1,6 @@
+import pytest
+
+
 def test_execute_many(conn):
     cur = conn.cursor()
     rv = cur.execute("select 'foo'; select 'bar'")
@@ -10,6 +13,8 @@ def test_execute_many(conn):
 
 
 def test_execute_sequence(conn):
+    if conn.pgconn.server_version < 100000:
+        pytest.xfail("it doesn't work on pg < 10")
     cur = conn.cursor()
     rv = cur.execute("select %s, %s, %s", [1, "foo", None])
     assert rv is cur