aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_sqlite3/test_dbapi.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py27
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 18359e1a5e2..4eb4e180bf1 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:"