gh-100553: Improve accuracy of sqlite3.Row iter test (#100555)

This commit is contained in:
Nikita Sobolev 2022-12-28 03:58:05 +03:00 committed by GitHub
parent b0ea28913e
commit 3dc48dabd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,8 +179,14 @@ class RowFactoryTests(unittest.TestCase):
"""Checks if the row object is iterable"""
self.con.row_factory = sqlite.Row
row = self.con.execute("select 1 as a, 2 as b").fetchone()
for col in row:
pass
# Is iterable in correct order and produces valid results:
items = [col for col in row]
self.assertEqual(items, [1, 2])
# Is iterable the second time:
items = [col for col in row]
self.assertEqual(items, [1, 2])
def test_sqlite_row_as_tuple(self):
"""Checks if the row object can be converted to a tuple"""