]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Add tuple_row test 32/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 24 Feb 2021 18:22:50 +0000 (19:22 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 24 Feb 2021 18:24:24 +0000 (19:24 +0100)
tests/test_rows.py

index d2f9d97d7b9333b53679d94afbfd0594bacc036d..836db33d8d98a188b8b3c2e778a9b777a763ceb9 100644 (file)
@@ -1,6 +1,16 @@
 from psycopg3 import rows
 
 
+def test_tuple_row(conn):
+    conn.row_factory = rows.dict_row
+    assert conn.execute("select 1 as a").fetchone() == {"a": 1}
+    cur = conn.cursor(row_factory=rows.tuple_row)
+    row = cur.execute("select 1 as a").fetchone()
+    assert row == (1,)
+    assert type(row) is tuple
+    assert cur._tx.make_row is tuple
+
+
 def test_dict_row(conn):
     cur = conn.cursor(row_factory=rows.dict_row)
     cur.execute("select 'bob' as name, 3 as id")