Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(38918)

Delta Between Two Patch Sets: Lib/sqlite3/test/factory.py

Issue 10203: sqlite3.Row doesn't support sequence protocol
Left Patch Set: Created 5 years, 4 months ago
Right Patch Set: Created 5 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/sqlite3/dbapi2.py ('k') | Modules/_sqlite/row.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #-*- coding: iso-8859-1 -*- 1 #-*- coding: iso-8859-1 -*-
2 # pysqlite2/test/factory.py: tests for the various factories in pysqlite 2 # pysqlite2/test/factory.py: tests for the various factories in pysqlite
3 # 3 #
4 # Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de> 4 # Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
5 # 5 #
6 # This file is part of pysqlite. 6 # This file is part of pysqlite.
7 # 7 #
8 # This software is provided 'as-is', without any express or implied 8 # This software is provided 'as-is', without any express or implied
9 # warranty. In no event will the authors be held liable for any damages 9 # warranty. In no event will the authors be held liable for any damages
10 # arising from the use of this software. 10 # arising from the use of this software.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 """ Checks if the row object can act like a sequence """ 147 """ Checks if the row object can act like a sequence """
148 self.con.row_factory = sqlite.Row 148 self.con.row_factory = sqlite.Row
149 row = self.con.execute("select 1 as a, 2 as b").fetchone() 149 row = self.con.execute("select 1 as a, 2 as b").fetchone()
150 150
151 as_tuple = tuple(row) 151 as_tuple = tuple(row)
152 self.assertEqual(list(reversed(row)), list(reversed(as_tuple))) 152 self.assertEqual(list(reversed(row)), list(reversed(as_tuple)))
153 self.assertEqual(row[-1], 2) 153 self.assertEqual(row[-1], 2)
154 self.assertEqual(row[-2], 1) 154 self.assertEqual(row[-2], 1)
155 with self.assertRaises(IndexError): 155 with self.assertRaises(IndexError):
156 row[-3] 156 row[-3]
157 with self.assertRaisesRegex(IndexError,
158 "cannot fit 'int' into an "
159 "index-sized integer"):
160 row[2 ** 1000]
157 self.assertIsInstance(row, Sequence) 161 self.assertIsInstance(row, Sequence)
158 162
159 def tearDown(self): 163 def tearDown(self):
160 self.con.close() 164 self.con.close()
161 165
162 class TextFactoryTests(unittest.TestCase): 166 class TextFactoryTests(unittest.TestCase):
163 def setUp(self): 167 def setUp(self):
164 self.con = sqlite.connect(":memory:") 168 self.con = sqlite.connect(":memory:")
165 169
166 def CheckUnicode(self): 170 def CheckUnicode(self):
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 text_suite = unittest.makeSuite(TextFactoryTests, "Check") 242 text_suite = unittest.makeSuite(TextFactoryTests, "Check")
239 text_zero_bytes_suite = unittest.makeSuite(TextFactoryTestsWithEmbeddedZeroB ytes, "Check") 243 text_zero_bytes_suite = unittest.makeSuite(TextFactoryTestsWithEmbeddedZeroB ytes, "Check")
240 return unittest.TestSuite((connection_suite, cursor_suite, row_suite_compat, row_suite, text_suite, text_zero_bytes_suite)) 244 return unittest.TestSuite((connection_suite, cursor_suite, row_suite_compat, row_suite, text_suite, text_zero_bytes_suite))
241 245
242 def test(): 246 def test():
243 runner = unittest.TextTestRunner() 247 runner = unittest.TextTestRunner()
244 runner.run(suite()) 248 runner.run(suite())
245 249
246 if __name__ == "__main__": 250 if __name__ == "__main__":
247 test() 251 test()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+