]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Fixed broken tests after fixing async connection discrepancies
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 23 Nov 2020 15:27:37 +0000 (15:27 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 23 Nov 2020 17:05:58 +0000 (17:05 +0000)
tests/test_connection.py
tests/test_connection_async.py
tests/test_cursor.py
tests/test_cursor_async.py

index 80f7f0b5cf8bf97bae6a1c024eb7252a0a75f517..24efbf50b5f1d1ad302dc5220710b0185eb2d0cb 100644 (file)
@@ -7,8 +7,8 @@ import weakref
 from threading import Thread
 
 import psycopg3
-from psycopg3 import Connection, Notify
 from psycopg3 import encodings
+from psycopg3 import Connection, Notify
 from psycopg3.errors import UndefinedTable
 from psycopg3.conninfo import conninfo_to_dict
 
@@ -246,6 +246,7 @@ def test_set_encoding(conn):
         ("utf_8", "UTF8", "utf-8"),
         ("eucjp", "EUC_JP", "euc_jp"),
         ("euc-jp", "EUC_JP", "euc_jp"),
+        ("latin9", "LATIN9", "iso8859-15"),
     ],
 )
 def test_normalize_encoding(conn, enc, out, codec):
index 4c0a8da62699cf59938ca39e34f6f056fec42f1d..b21d771790ff07c890868d57f53e18f06fc3d72c 100644 (file)
@@ -8,7 +8,7 @@ import weakref
 
 import psycopg3
 from psycopg3 import encodings
-from psycopg3 import AsyncConnection
+from psycopg3 import AsyncConnection, Notify
 from psycopg3.errors import UndefinedTable
 from psycopg3.conninfo import conninfo_to_dict
 
@@ -298,14 +298,14 @@ async def test_encoding_env_var(dsn, monkeypatch, enc, out, codec):
 
 
 async def test_set_encoding_unsupported(aconn):
-    await aconn.set_client_encoding("EUC_TW")
     cur = await aconn.cursor()
+    await cur.execute("set client_encoding to EUC_TW")
     with pytest.raises(psycopg3.NotSupportedError):
-        await cur.execute("select 1")
+        await cur.execute("select 'x'")
 
 
 async def test_set_encoding_bad(aconn):
-    with pytest.raises(psycopg3.DatabaseError):
+    with pytest.raises(LookupError):
         await aconn.set_client_encoding("WAT")
 
 
@@ -438,6 +438,7 @@ async def test_notify_handlers(aconn):
     assert len(nots1) == 1
     assert len(nots2) == 2
     n = nots2[1]
+    assert isinstance(n, Notify)
     assert n.channel == "foo"
     assert n.payload == "n2"
     assert n.pid == aconn.pgconn.backend_pid
index 24d4e4004eef36857f344032cf1d302b91c78654..36ca400512d3800de85943565fa525ef36b10349 100644 (file)
@@ -239,8 +239,8 @@ def test_query_params_execute(conn):
     assert cur.query is None
     assert cur.params is None
 
-    cur.execute("select %s, %s", [1, None])
-    assert cur.query == b"select $1, $2"
+    cur.execute("select %s, %s::text", [1, None])
+    assert cur.query == b"select $1, $2::text"
     assert cur.params == [b"1", None]
 
     cur.execute("select 1")
index 9a1644f4bbc46293c75eb76c70038cb84699838e..7c3750b61104d0486b094200d74dcb35243b9042 100644 (file)
@@ -227,8 +227,8 @@ async def test_query_params_execute(aconn):
     assert cur.query is None
     assert cur.params is None
 
-    await cur.execute("select %s, %s", [1, None])
-    assert cur.query == b"select $1, $2"
+    await cur.execute("select %s, %s::text", [1, None])
+    assert cur.query == b"select $1, $2::text"
     assert cur.params == [b"1", None]
 
     await cur.execute("select 1")