From: Daniele Varrazzo Date: Wed, 5 May 2021 16:32:06 +0000 (+0200) Subject: Fix test for ConnectionInfo.hostaddr and libpq < 12 X-Git-Tag: 3.0.dev0~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5a0a72ab1b610983ef27ed8296e52d09b0ae76a;p=thirdparty%2Fpsycopg.git Fix test for ConnectionInfo.hostaddr and libpq < 12 --- diff --git a/docs/api/connections.rst b/docs/api/connections.rst index 113dec25b..813736391 100644 --- a/docs/api/connections.rst +++ b/docs/api/connections.rst @@ -283,6 +283,9 @@ Connection support objects .. autoattribute:: hostaddr + Only available if the libpq used is at least from PostgreSQL 12. + Raise `~psycopg3.NotSupportedError` otherwise. + .. autoattribute:: port .. autoattribute:: dbname .. autoattribute:: user diff --git a/tests/test_conninfo.py b/tests/test_conninfo.py index ff5e9544e..be1e706ed 100644 --- a/tests/test_conninfo.py +++ b/tests/test_conninfo.py @@ -98,6 +98,9 @@ class TestConnectionInfo: else: info_attr = pgconn_attr = attr + if info_attr == "hostaddr" and psycopg3.pq.version() < 120000: + pytest.skip("hostaddr not supported on libpq < 12") + info_val = getattr(conn.info, info_attr) pgconn_val = getattr(conn.pgconn, pgconn_attr).decode("utf-8") assert info_val == pgconn_val @@ -106,6 +109,11 @@ class TestConnectionInfo: with pytest.raises(psycopg3.OperationalError): getattr(conn.info, info_attr) + @pytest.mark.libpq("< 12") + def test_hostaddr_not_supported(self, conn): + with pytest.raises(psycopg3.NotSupportedError): + conn.info.hostaddr + def test_port(self, conn): assert conn.info.port == int(conn.pgconn.port.decode("utf-8")) conn.close()