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
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 == []