From e7c26491ca45c5d72e42b9cc72d5ef6fe972b90c Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 13 Jan 2021 14:55:59 +0100 Subject: [PATCH] Added xfail to a binary empty array test Fixing it requires reconsidering how to deal with parameters formats. Also fixed xpass to make sure to spot the tests to fix after fixing the above. --- tests/pq/test_pgconn.py | 13 +++++++++---- tests/types/test_array.py | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/pq/test_pgconn.py b/tests/pq/test_pgconn.py index fece93f3c..7eabfa5e1 100644 --- a/tests/pq/test_pgconn.py +++ b/tests/pq/test_pgconn.py @@ -202,15 +202,20 @@ def test_host(pgconn): pgconn.host -# TODO: to implement in psycopg3_c.pq -@pytest.mark.xfail @pytest.mark.libpq(">= 12") def test_hostaddr(pgconn): # not in info assert isinstance(pgconn.hostaddr, bytes), pgconn.hostaddr pgconn.finish() - with pytest.raises(psycopg3.OperationalError): - pgconn.hostaddr + if psycopg3.pq.__impl__ == "python": + with pytest.raises(psycopg3.OperationalError): + pgconn.hostaddr + + else: + if pgconn.hostaddr == b"TODO": + pytest.xfail("implement hostaddr in psycopg3_c.pq") + else: + assert False, "you did it! not fix the test" @pytest.mark.xfail diff --git a/tests/types/test_array.py b/tests/types/test_array.py index 017be4155..a772a7526 100644 --- a/tests/types/test_array.py +++ b/tests/types/test_array.py @@ -147,9 +147,23 @@ def test_empty_list_mix(conn, fmt_in): objs = list(range(3)) # pro tip: don't get confused with the types conn.execute("create table testarrays (col1 bigint[], col2 bigint[])") - f1, f2 = conn.execute( - f"insert into testarrays values ({ph}, {ph}) returning *", (objs, []) - ).fetchone() + if fmt_in == Format.TEXT: + f1, f2 = conn.execute( + f"insert into testarrays values ({ph}, {ph}) returning *", + (objs, []), + ).fetchone() + else: + # TODO: fix passing empty lists in binary format + try: + f1, f2 = conn.execute( + f"insert into testarrays values ({ph}, {ph}) returning *", + (objs, []), + ).fetchone() + except psycopg3.errors.DatatypeMismatch: + pytest.xfail("empty lists in binary format not supported") + else: + assert False, "you fixed the thing, now fix the test!" + assert f1 == objs assert f2 == [] -- 2.47.2