From: Daniele Varrazzo Date: Sun, 5 Jun 2022 16:58:37 +0000 (+0200) Subject: test: add test to reveal unexpected message received X-Git-Tag: 3.1~64^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0cb861cda20e1fb939202c868aa9820805064be;p=thirdparty%2Fpsycopg.git test: add test to reveal unexpected message received The test fails because we receive a notification: message type 0x33 arrived from server while idle See issue #314. --- diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 841379bb9..dd890f849 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -487,6 +487,18 @@ def test_rollback_transaction(conn): conn.execute("select 1") +def test_message_0x33(conn): + notices = [] + conn.add_notice_handler(lambda diag: notices.append(diag.message_primary)) + + conn.autocommit = True + with conn.pipeline(): + cur = conn.execute("select 'test'") + cur.fetchone() == ("test",) + + assert not notices + + def test_concurrency(conn): with conn.transaction(): conn.execute("drop table if exists pipeline_concurrency") diff --git a/tests/test_pipeline_async.py b/tests/test_pipeline_async.py index c170dfa23..ef929b3b1 100644 --- a/tests/test_pipeline_async.py +++ b/tests/test_pipeline_async.py @@ -489,6 +489,18 @@ async def test_rollback_transaction(aconn): await aconn.execute("select 1") +async def test_message_0x33(aconn): + notices = [] + aconn.add_notice_handler(lambda diag: notices.append(diag.message_primary)) + + await aconn.set_autocommit(True) + async with aconn.pipeline(): + cur = await aconn.execute("select 'test'") + await cur.fetchone() == ("test",) + + assert not notices + + async def test_concurrency(aconn): async with aconn.transaction(): await aconn.execute("drop table if exists pipeline_concurrency")