]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added xfail to a binary empty array test
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Jan 2021 13:55:59 +0000 (14:55 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Jan 2021 14:15:47 +0000 (15:15 +0100)
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
tests/types/test_array.py

index fece93f3cb425faf1d1aaae61139744205e36b83..7eabfa5e13680a267bcd85b187a045600ee8283b 100644 (file)
@@ -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
index 017be4155bb24d10c4c7ed3ef0e01dbf8cf1059b..a772a7526d187655790de4fd3a44dc146a57ce10 100644 (file)
@@ -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 == []