]> 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:16:53 +0000 (17:16 -0800)
committerGitHub <noreply@github.com>
Wed, 28 Dec 2022 01:16:53 +0000 (17:16 -0800)
(cherry picked from commit 3dc48dabd48864039951715816e07986a4828d80)

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

index 876428497542f84972adb2f02e2945a1cfa867fe..40a290f0c9816fb6f62b96137c236f8bbfa86ed5 100644 (file)
@@ -155,8 +155,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"""