psycopg.git / summary / log / commit / refs
commit 58fee6eaffe1dc092fb693dacfcb92931da0502e
Author: Daniele Varrazzo <daniele.varrazzo@gmail.com>
Date: Mon Nov 23 15:27:37 2020 +0000
Fixed broken tests after fixing async connection discrepancies
tests/test_connection.py | 3 ++-
tests/test_connection_async.py | 9 +++++----
tests/test_cursor.py | 4 ++--
tests/test_cursor_async.py | 4 ++--
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 80f7f0b5..24efbf50 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 4c0a8da6..b21d7717 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 24d4e400..36ca4005 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 9a1644f4..7c3750b6 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")
[parent: 8dffb74d6348]