@@ -110,9 +110,8 @@ async def t3() -> None:
110110
111111@dbs_all
112112async def test_transaction_manual_work (db : AioDatabase ) -> None :
113- async with db .aio_connection () as connection :
114- tr = Transaction (connection )
115- await tr .begin ()
113+ async with db .aio_connection ():
114+ tr = await db .aio_begin ()
116115 await TestModel .aio_create (text = "FOO" )
117116 assert await TestModel .aio_get_or_none (text = "FOO" ) is not None
118117 try :
@@ -126,6 +125,15 @@ async def test_transaction_manual_work(db: AioDatabase) -> None:
126125 assert db .pool_backend .has_acquired_connections () is False
127126
128127
128+ @dbs_all
129+ async def test_aio_begin_savepoint_error (db : AioDatabase ) -> None :
130+ with pytest .raises (OperationalError ):
131+ await db .aio_begin ()
132+
133+ with pytest .raises (OperationalError ):
134+ await db .aio_savepoint ()
135+
136+
129137@pytest .mark .parametrize (
130138 ("method1" , "method2" ),
131139 [
@@ -180,14 +188,12 @@ async def test_savepoint_rollback(db: AioDatabase) -> None:
180188
181189@dbs_all
182190async def test_savepoint_manual_work (db : AioDatabase ) -> None :
183- async with db .aio_connection () as connection :
184- tr = Transaction (connection )
185- await tr .begin ()
191+ async with db .aio_connection ():
192+ tr = await db .aio_begin ()
186193 await TestModel .aio_create (text = "FOO" )
187194 assert await TestModel .aio_get_or_none (text = "FOO" ) is not None
188195
189- savepoint = Transaction (connection , is_savepoint = True )
190- await savepoint .begin ()
196+ savepoint = await db .aio_savepoint ()
191197 try :
192198 await TestModel .aio_create (text = "FOO" )
193199 except : # noqa: E722
0 commit comments