diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-11-17 11:01:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 19:01:54 +0900 |
commit | 5f9247e36a0213b0dcfd43533db5cf6570895cfd (patch) | |
tree | 171b6ecb0d3818fc633d45c251faf13a0408fe63 /Lib/test/test_sqlite3/test_dbapi.py | |
parent | 15409c720be0503131713e3d3abc1acd0da07378 (diff) | |
download | cpython-git-5f9247e36a0213b0dcfd43533db5cf6570895cfd.tar.gz |
bpo-45512: Extend `sqlite3` test suite regarding isolation levels (GH-29576)
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r-- | Lib/test/test_sqlite3/test_dbapi.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 18359e1a5e..4eb4e180bf 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -514,14 +514,35 @@ class ConnectionTests(unittest.TestCase): "isolation_level string must be '', 'DEFERRED', 'IMMEDIATE', or " "'EXCLUSIVE'" ) - with self.assertRaisesRegex(ValueError, msg): - memory_database(isolation_level="BOGUS") + levels = ( + "BOGUS", + " ", + "DEFERRE", + "IMMEDIAT", + "EXCLUSIV", + "DEFERREDS", + "IMMEDIATES", + "EXCLUSIVES", + ) + for level in levels: + with self.subTest(level=level): + with self.assertRaisesRegex(ValueError, msg): + memory_database(isolation_level=level) + with memory_database() as cx: + with self.assertRaisesRegex(ValueError, msg): + cx.isolation_level = level + # Check that the default level is not changed + self.assertEqual(cx.isolation_level, "") def test_connection_init_good_isolation_levels(self): for level in ("", "DEFERRED", "IMMEDIATE", "EXCLUSIVE", None): with self.subTest(level=level): with memory_database(isolation_level=level) as cx: - cx.execute("select 'ok'") + self.assertEqual(cx.isolation_level, level) + with memory_database() as cx: + self.assertEqual(cx.isolation_level, "") + cx.isolation_level = level + self.assertEqual(cx.isolation_level, level) def test_connection_reinit(self): db = ":memory:" |