Skip to content

Commit f2f70ee

Browse files
authored
Merge pull request #75 from michalc/test/higher-code-coverage-in-tests
test: avoid iterating once in for loops to avoid partial coverage in tests
2 parents fc8e611 + e30e3ea commit f2f70ee

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ def test_select_multi(self):
233233
SELECT my_col_a FROM my_table;
234234
SELECT my_col_a FROM my_table LIMIT 10;
235235
'''):
236-
for row in rows:
237-
raise Exception('Just after iterating first row')
236+
rows_it = iter(rows)
237+
next(rows_it)
238+
raise Exception('Just after iterating first row')
238239

239240
with self.assertRaisesRegex(Exception, 'Multiple open statements'):
240241
with sqlite_s3_query_multi('http://localhost:9000/my-bucket/my.db', get_credentials=lambda now: (
@@ -248,12 +249,13 @@ def test_select_multi(self):
248249
SELECT my_col_a FROM my_table LIMIT 10;
249250
'''))
250251
columns_1, rows_1 = next(it)
251-
for row in rows_1:
252-
break
252+
rows_1_it = iter(rows_1)
253+
next(rows_1_it)
253254

254255
columns_2, rows_2 = next(it)
255-
for row in rows_2:
256-
raise Exception('Multiple open statements')
256+
rows_2_it = iter(rows_2)
257+
next(rows_2_it)
258+
raise Exception('Multiple open statements')
257259

258260
with self.assertRaisesRegex(Exception, 'Attempting to use finalized statement'):
259261
with sqlite_s3_query_multi('http://localhost:9000/my-bucket/my.db', get_credentials=lambda now: (

0 commit comments

Comments
 (0)