From: Daniele Varrazzo Date: Mon, 23 Nov 2020 15:27:37 +0000 (+0000) Subject: Fixed broken tests after fixing async connection discrepancies X-Git-Tag: 3.0.dev0~319 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58fee6eaffe1dc092fb693dacfcb92931da0502e;p=thirdparty%2Fpsycopg.git Fixed broken tests after fixing async connection discrepancies --- diff --git a/tests/test_connection.py b/tests/test_connection.py index 80f7f0b5c..24efbf50b 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -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): diff --git a/tests/test_connection_async.py b/tests/test_connection_async.py index 4c0a8da62..b21d77179 100644 --- a/tests/test_connection_async.py +++ b/tests/test_connection_async.py @@ -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 diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 24d4e4004..36ca40051 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -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") diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index 9a1644f4b..7c3750b61 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -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")