From: Daniele Varrazzo Date: Tue, 24 Mar 2020 11:34:11 +0000 (+1300) Subject: Skip certain tests on PG < 10 X-Git-Tag: 3.0.dev0~672 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=154ec8179c621ac64ca1b5da59f6afe712380c2a;p=thirdparty%2Fpsycopg.git Skip certain tests on PG < 10 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. --- diff --git a/tests/fix_async.py b/tests/fix_async.py index fb7c0ac0c..5bd4c0b70 100644 --- a/tests/fix_async.py +++ b/tests/fix_async.py @@ -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 diff --git a/tests/fix_db.py b/tests/fix_db.py index 843c29540..140fa9d13 100644 --- a/tests/fix_db.py +++ b/tests/fix_db.py @@ -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 diff --git a/tests/pq/test_exec.py b/tests/pq/test_exec.py index e991d753c..e7579d71b 100644 --- a/tests/pq/test_exec.py +++ b/tests/pq/test_exec.py @@ -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" diff --git a/tests/test_async_cursor.py b/tests/test_async_cursor.py index 4c0dfd57c..4c9e0e587 100644 --- a/tests/test_async_cursor.py +++ b/tests/test_async_cursor.py @@ -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]) diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 52fc3f817..658153ff9 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -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