@@ -50,6 +50,18 @@ def _test_isolation_level_read_only(
5050
5151 maybe_await (cursor .execute_scheme ("DROP TABLE foo" ))
5252
53+ def _test_commit_rollback_after_begin (self , connection : dbapi .Connection , isolation_level : str ) -> None :
54+ connection .set_isolation_level (isolation_level )
55+
56+ for _ in range (10 ):
57+ maybe_await (connection .begin ())
58+ maybe_await (connection .commit ())
59+
60+ for _ in range (10 ):
61+ maybe_await (connection .begin ())
62+ maybe_await (connection .rollback ())
63+
64+
5365 def _test_connection (self , connection : dbapi .Connection ) -> None :
5466 maybe_await (connection .commit ())
5567 maybe_await (connection .rollback ())
@@ -377,6 +389,26 @@ def test_isolation_level_read_only(
377389 connection , isolation_level , read_only
378390 )
379391
392+ @pytest .mark .parametrize (
393+ ("isolation_level" ),
394+ [
395+ (dbapi .IsolationLevel .SERIALIZABLE ),
396+ (dbapi .IsolationLevel .AUTOCOMMIT ),
397+ (dbapi .IsolationLevel .ONLINE_READONLY ),
398+ (dbapi .IsolationLevel .ONLINE_READONLY_INCONSISTENT ),
399+ (dbapi .IsolationLevel .STALE_READONLY ),
400+ (dbapi .IsolationLevel .SNAPSHOT_READONLY ),
401+ ],
402+ )
403+ def test_commit_rollback_after_begin (
404+ self ,
405+ isolation_level : str ,
406+ connection : dbapi .Connection ,
407+ ) -> None :
408+ self ._test_commit_rollback_after_begin (
409+ connection , isolation_level
410+ )
411+
380412 def test_connection (self , connection : dbapi .Connection ) -> None :
381413 self ._test_connection (connection )
382414
@@ -448,6 +480,29 @@ async def test_isolation_level_read_only(
448480 read_only ,
449481 )
450482
483+ @pytest .mark .asyncio
484+ @pytest .mark .parametrize (
485+ ("isolation_level" ),
486+ [
487+ (dbapi .IsolationLevel .SERIALIZABLE ),
488+ (dbapi .IsolationLevel .AUTOCOMMIT ),
489+ (dbapi .IsolationLevel .ONLINE_READONLY ),
490+ (dbapi .IsolationLevel .ONLINE_READONLY_INCONSISTENT ),
491+ (dbapi .IsolationLevel .STALE_READONLY ),
492+ (dbapi .IsolationLevel .SNAPSHOT_READONLY ),
493+ ],
494+ )
495+ async def test_commit_rollback_after_begin (
496+ self ,
497+ isolation_level : str ,
498+ connection : dbapi .AsyncConnection ,
499+ ) -> None :
500+ await greenlet_spawn (
501+ self ._test_commit_rollback_after_begin ,
502+ connection ,
503+ isolation_level
504+ )
505+
451506 @pytest .mark .asyncio
452507 async def test_connection (self , connection : dbapi .AsyncConnection ) -> None :
453508 await greenlet_spawn (self ._test_connection , connection )
0 commit comments