From a84a1285039b5d77a70ce4c04af54c492f5b801d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 2 Aug 2021 01:43:25 +0200 Subject: [PATCH] Test that the row_cursor param can be set explicitly to none --- tests/test_cursor.py | 8 ++++++++ tests/test_cursor_async.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/test_cursor.py b/tests/test_cursor.py index e1faa6a56..c11178987 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -304,6 +304,14 @@ def test_row_factory(conn): assert cur.fetchone() == {"y": "y", "z": "z"} +def test_row_factory_none(conn): + cur = conn.cursor(row_factory=None) + assert cur.row_factory is rows.tuple_row + r = cur.execute("select 1 as a, 2 as b").fetchone() + assert type(r) is tuple + assert r == (1, 2) + + def test_bad_row_factory(conn): def broken_factory(cur): 1 / 0 diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index b29070f02..0c61a2fa5 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -310,6 +310,15 @@ async def test_row_factory(aconn): assert await cur.fetchone() == {"y": "y", "z": "z"} +async def test_row_factory_none(aconn): + cur = aconn.cursor(row_factory=None) + assert cur.row_factory is rows.tuple_row + await cur.execute("select 1 as a, 2 as b") + r = await cur.fetchone() + assert type(r) is tuple + assert r == (1, 2) + + async def test_bad_row_factory(aconn): def broken_factory(cur): 1 / 0 -- 2.47.3