]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor(tests): auto-generate test_client_cursor from async counterpart
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 10 Aug 2023 00:16:31 +0000 (01:16 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 11 Oct 2023 21:45:38 +0000 (23:45 +0200)
tests/test_client_cursor.py
tools/async_to_sync.py
tools/convert_async_to_sync.sh

index d8b4e5abf72cd760c060e7068b9c908d28c60c6c..ee6a69ee77e26bf5351dbeb8c9321037b01ab02d 100644 (file)
@@ -1,3 +1,6 @@
+# WARNING: this file is auto-generated by 'async_to_sync.py'
+# from the original file 'test_client_cursor_async.py'
+# DO NOT CHANGE! Change the original file instead.
 import datetime as dt
 
 import pytest
@@ -9,7 +12,7 @@ from .fix_crdb import crdb_encoding
 
 
 @pytest.fixture
-def conn(conn):
+def conn(conn, anyio_backend):
     conn.cursor_factory = psycopg.ClientCursor
     return conn
 
@@ -133,12 +136,12 @@ def test_mogrify(conn, query, params, want):
 @pytest.mark.parametrize("encoding", ["utf8", crdb_encoding("latin9")])
 def test_mogrify_encoding(conn, encoding):
     conn.execute(f"set client_encoding to {encoding}")
-    q = conn.cursor().mogrify("select %(s)s", {"s": "\u20ac"})
-    assert q == "select '\u20ac'"
+    q = conn.cursor().mogrify("select %(s)s", {"s": ""})
+    assert q == "select ''"
 
 
 @pytest.mark.parametrize("encoding", [crdb_encoding("latin1")])
 def test_mogrify_badenc(conn, encoding):
     conn.execute(f"set client_encoding to {encoding}")
     with pytest.raises(UnicodeEncodeError):
-        conn.cursor().mogrify("select %(s)s", {"s": "\u20ac"})
+        conn.cursor().mogrify("select %(s)s", {"s": ""})
index 25d6273639c266aca3a7293c2ba0aa11eb0617fd..706dc66b88cf6955a759572340e60c9f89e5246c 100755 (executable)
@@ -116,6 +116,7 @@ class RenameAsyncToSync(ast.NodeTransformer):
         "aconn_set": "conn_set",
         "alist": "list",
         "anext": "next",
+        "find_insert_problem_async": "find_insert_problem",
     }
 
     def visit_Module(self, node: ast.Module) -> ast.AST:
index 8727c54064ee0fba9d4e0f0509ba583e7d72c190..637cd6083265c2bee141700492c9b9ceacab1e05 100755 (executable)
@@ -8,6 +8,7 @@ dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 cd "${dir}/.."
 
 for async in \
+    tests/test_client_cursor_async.py \
     tests/test_connection_async.py \
     tests/test_cursor_async.py \
     tests/test_pipeline_async.py