]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: test that the host is in the error message on name resolution error
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 16 Nov 2025 15:17:46 +0000 (16:17 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 16 Nov 2025 15:20:26 +0000 (16:20 +0100)
tests/test_connection.py
tests/test_connection_async.py

index 6b7ee93b80f471b0db84f6a7eacc83f84d1c40b8..6b842b142c36784da9c19d9f61eee16e9cd0e54c 100644 (file)
@@ -506,6 +506,14 @@ def test_connect_args(
     conn.close()
 
 
+def test_resolve_error_host(conn_cls):
+    host = "nosuchhost.example.com"
+    with pytest.raises(psycopg.OperationalError) as ex:
+        conn_cls.connect(host=host)
+
+    assert host in str(ex.value)
+
+
 @pytest.mark.parametrize(
     "args, kwargs, exctype",
     [
index 8e70947af41df30e9c591ecce98b418ea103a497..6a8f05349dec40a9339561b3eff7c0663f12d8e1 100644 (file)
@@ -502,6 +502,14 @@ async def test_connect_args(
     await conn.close()
 
 
+async def test_resolve_error_host(aconn_cls):
+    host = "nosuchhost.example.com"
+    with pytest.raises(psycopg.OperationalError) as ex:
+        await aconn_cls.connect(host=host)
+
+    assert host in str(ex.value)
+
+
 @pytest.mark.parametrize(
     "args, kwargs, exctype",
     [