]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Test that the row_cursor param can be set explicitly to none
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 1 Aug 2021 23:43:25 +0000 (01:43 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 3 Aug 2021 10:57:53 +0000 (11:57 +0100)
tests/test_cursor.py
tests/test_cursor_async.py

index e1faa6a564ddec67bb7d1152fa92c14328340bc6..c1117898759e60d4965aafd6b222c7d3b242c750 100644 (file)
@@ -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
index b29070f02280f43309a05a6071e0c48d4d4ec81a..0c61a2fa5df8f9e553a2a5db3f7cbd71bef8ae53 100644 (file)
@@ -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