@@ -50,6 +50,22 @@ def _test_isolation_level_read_only(
5050
5151 maybe_await (cursor .execute_scheme ("DROP TABLE foo" ))
5252
53+ def _test_commit_rollback_after_begin (
54+ self ,
55+ connection : dbapi .Connection ,
56+ isolation_level : str ,
57+ ) -> None :
58+ connection .set_isolation_level (isolation_level )
59+
60+ for _ in range (10 ):
61+ maybe_await (connection .begin ())
62+ maybe_await (connection .commit ())
63+
64+ for _ in range (10 ):
65+ maybe_await (connection .begin ())
66+ maybe_await (connection .rollback ())
67+
68+
5369 def _test_connection (self , connection : dbapi .Connection ) -> None :
5470 maybe_await (connection .commit ())
5571 maybe_await (connection .rollback ())
@@ -377,6 +393,26 @@ def test_isolation_level_read_only(
377393 connection , isolation_level , read_only
378394 )
379395
396+ @pytest .mark .parametrize (
397+ ("isolation_level" ),
398+ [
399+ (dbapi .IsolationLevel .SERIALIZABLE ),
400+ (dbapi .IsolationLevel .AUTOCOMMIT ),
401+ (dbapi .IsolationLevel .ONLINE_READONLY ),
402+ (dbapi .IsolationLevel .ONLINE_READONLY_INCONSISTENT ),
403+ (dbapi .IsolationLevel .STALE_READONLY ),
404+ (dbapi .IsolationLevel .SNAPSHOT_READONLY ),
405+ ],
406+ )
407+ def test_commit_rollback_after_begin (
408+ self ,
409+ isolation_level : str ,
410+ connection : dbapi .Connection ,
411+ ) -> None :
412+ self ._test_commit_rollback_after_begin (
413+ connection , isolation_level
414+ )
415+
380416 def test_connection (self , connection : dbapi .Connection ) -> None :
381417 self ._test_connection (connection )
382418
@@ -448,6 +484,29 @@ async def test_isolation_level_read_only(
448484 read_only ,
449485 )
450486
487+ @pytest .mark .asyncio
488+ @pytest .mark .parametrize (
489+ ("isolation_level" ),
490+ [
491+ (dbapi .IsolationLevel .SERIALIZABLE ),
492+ (dbapi .IsolationLevel .AUTOCOMMIT ),
493+ (dbapi .IsolationLevel .ONLINE_READONLY ),
494+ (dbapi .IsolationLevel .ONLINE_READONLY_INCONSISTENT ),
495+ (dbapi .IsolationLevel .STALE_READONLY ),
496+ (dbapi .IsolationLevel .SNAPSHOT_READONLY ),
497+ ],
498+ )
499+ async def test_commit_rollback_after_begin (
500+ self ,
501+ isolation_level : str ,
502+ connection : dbapi .AsyncConnection ,
503+ ) -> None :
504+ await greenlet_spawn (
505+ self ._test_commit_rollback_after_begin ,
506+ connection ,
507+ isolation_level
508+ )
509+
451510 @pytest .mark .asyncio
452511 async def test_connection (self , connection : dbapi .AsyncConnection ) -> None :
453512 await greenlet_spawn (self ._test_connection , connection )
0 commit comments