]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100553: Improve accuracy of sqlite3.Row iter test (GH-100555)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 28 Dec 2022 01:25:28 +0000 (17:25 -0800)
committerGitHub <noreply@github.com>
Wed, 28 Dec 2022 01:25:28 +0000 (17:25 -0800)
(cherry picked from commit 3dc48dabd48864039951715816e07986a4828d80)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_sqlite3/test_factory.py

index cdaf12588a7f47148ea5efb04ccd9f56adba0cd4..2b70093bd9b68d2e5ca56c924b51b1edb9e38641 100644 (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"""