@@ -509,6 +509,20 @@ def test_connection_bad_limit_category(self):
509
509
self .assertRaisesRegex (sqlite .ProgrammingError , msg ,
510
510
self .cx .setlimit , cat , 0 )
511
511
512
+ def test_connection_init_bad_isolation_level (self ):
513
+ msg = (
514
+ "isolation_level string must be '', 'DEFERRED', 'IMMEDIATE', or "
515
+ "'EXCLUSIVE'"
516
+ )
517
+ with self .assertRaisesRegex (ValueError , msg ):
518
+ memory_database (isolation_level = "BOGUS" )
519
+
520
+ def test_connection_init_good_isolation_levels (self ):
521
+ for level in ("" , "DEFERRED" , "IMMEDIATE" , "EXCLUSIVE" , None ):
522
+ with self .subTest (level = level ):
523
+ with memory_database (isolation_level = level ) as cx :
524
+ cx .execute ("select 'ok'" )
525
+
512
526
def test_connection_reinit (self ):
513
527
db = ":memory:"
514
528
cx = sqlite .connect (db )
@@ -547,14 +561,6 @@ def test_connection_bad_reinit(self):
547
561
cx .executemany , "insert into t values(?)" ,
548
562
((v ,) for v in range (3 )))
549
563
550
- def test_connection_init_bad_isolation_level (self ):
551
- msg = (
552
- "isolation_level string must be '', 'DEFERRED', 'IMMEDIATE', or "
553
- "'EXCLUSIVE'"
554
- )
555
- with self .assertRaisesRegex (ValueError , msg ):
556
- memory_database (isolation_level = "BOGUS" )
557
-
558
564
559
565
class UninitialisedConnectionTests (unittest .TestCase ):
560
566
def setUp (self ):
0 commit comments