diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-08-26 19:08:51 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-08-26 19:08:51 (GMT) |
commit | 6ed442c48dd7f8d3097e688a36bc027df3271621 (patch) | |
tree | 64ee7c4057f3f862a4522f2020eb1f89883bb96c /Lib/sqlite3 | |
parent | f74c33ad5c94f1f07f574336dc2d5a6345acdcc7 (diff) | |
parent | cc9afa9b517fd66bad148f546055985ad87bc816 (diff) | |
download | cpython-6ed442c48dd7f8d3097e688a36bc027df3271621.zip cpython-6ed442c48dd7f8d3097e688a36bc027df3271621.tar.gz cpython-6ed442c48dd7f8d3097e688a36bc027df3271621.tar.bz2 |
Issue #10513: Merge from 3.5
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/regression.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 44974b0..cb465ba 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -322,6 +322,37 @@ class RegressionTests(unittest.TestCase): self.assertRaises(ValueError, cur.execute, " \0select 2") self.assertRaises(ValueError, cur.execute, "select 2\0") + def CheckCommitCursorReset(self): + """ + Connection.commit() did reset cursors, which made sqlite3 + to return rows multiple times when fetched from cursors + after commit. See issues 10513 and 23129 for details. + """ + con = sqlite.connect(":memory:") + con.executescript(""" + create table t(c); + create table t2(c); + insert into t values(0); + insert into t values(1); + insert into t values(2); + """) + + self.assertEqual(con.isolation_level, "") + + counter = 0 + for i, row in enumerate(con.execute("select c from t")): + with self.subTest(i=i, row=row): + con.execute("insert into t2(c) values (?)", (i,)) + con.commit() + if counter == 0: + self.assertEqual(row[0], 0) + elif counter == 1: + self.assertEqual(row[0], 1) + elif counter == 2: + self.assertEqual(row[0], 2) + counter += 1 + self.assertEqual(counter, 3, "should have returned exactly three rows") + def suite(): regression_suite = unittest.makeSuite(RegressionTests, "Check") |