From: Daniele Varrazzo Date: Wed, 1 Feb 2023 00:39:51 +0000 (+0100) Subject: test: reproduce the error in TypeInfo.fetch() in sql_ascii connection X-Git-Tag: pool-3.2.0~127^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5175d214d8054af60421a0d66304346cf310dbfa;p=thirdparty%2Fpsycopg.git test: reproduce the error in TypeInfo.fetch() in sql_ascii connection Reported in #503. --- diff --git a/tests/test_typeinfo.py b/tests/test_typeinfo.py index 56dab053d..063c57762 100644 --- a/tests/test_typeinfo.py +++ b/tests/test_typeinfo.py @@ -9,10 +9,18 @@ from psycopg.types.enum import EnumInfo from psycopg.types.multirange import MultirangeInfo from psycopg.types.range import RangeInfo +from .fix_crdb import crdb_encoding + @pytest.mark.parametrize("name", ["text", sql.Identifier("text")]) @pytest.mark.parametrize("status", ["IDLE", "INTRANS"]) -def test_fetch(conn, name, status): +@pytest.mark.parametrize( + "encoding", ["utf8", crdb_encoding("latin1"), crdb_encoding("sql_ascii")] +) +def test_fetch(conn, name, status, encoding): + with conn.transaction(): + conn.execute("select set_config('client_encoding', %s, false)", [encoding]) + status = getattr(TransactionStatus, status) if status == TransactionStatus.INTRANS: conn.execute("select 1") @@ -33,7 +41,15 @@ def test_fetch(conn, name, status): @pytest.mark.asyncio @pytest.mark.parametrize("name", ["text", sql.Identifier("text")]) @pytest.mark.parametrize("status", ["IDLE", "INTRANS"]) -async def test_fetch_async(aconn, name, status): +@pytest.mark.parametrize( + "encoding", ["utf8", crdb_encoding("latin1"), crdb_encoding("sql_ascii")] +) +async def test_fetch_async(aconn, name, status, encoding): + async with aconn.transaction(): + await aconn.execute( + "select set_config('client_encoding', %s, false)", [encoding] + ) + status = getattr(TransactionStatus, status) if status == TransactionStatus.INTRANS: await aconn.execute("select 1")