@@ -40,7 +40,7 @@ async def test_connection_ctx(bind, mocker):
4040 tx = await conn .transaction ().__aenter__ ()
4141 await u .update (nickname = "rollback" ).apply ()
4242 assert await get_name () == "rollback"
43- mocker .patch ("asyncpg.transaction.Transaction .commit" ).side_effect = IndexError
43+ mocker .patch ("aiomysql.connection.Connection .commit" ).side_effect = IndexError
4444 with pytest .raises (IndexError ):
4545 await tx .__aexit__ (None , None , None )
4646 # clean up, and to simulate commit failed
@@ -102,38 +102,38 @@ async def test_engine(bind):
102102
103103
104104async def test_begin_failed (bind , mocker ):
105- from asyncpg . transaction import Transaction
105+ from aiomysql . connection import Connection
106106
107107 init_size = qsize (bind )
108- mocker .patch ("asyncpg.transaction.Transaction.start " )
109- Transaction . start .side_effect = ZeroDivisionError
108+ mocker .patch ("aiomysql.connection.Connection.begin " )
109+ Connection . begin .side_effect = ZeroDivisionError
110110 with pytest .raises (ZeroDivisionError ):
111111 async with bind .transaction ():
112112 pass # pragma: no cover
113113 assert init_size == qsize (bind )
114114
115115
116116async def test_commit_failed (bind , mocker ):
117- from asyncpg . transaction import Transaction
117+ from aiomysql . connection import Connection
118118
119119 init_size = qsize (bind )
120- mocker .patch ("asyncpg.transaction.Transaction._Transaction__commit " )
120+ mocker .patch ("aiomysql.connection.Connection.begin " )
121121 # noinspection PyUnresolvedReferences,PyProtectedMember
122- Transaction . _Transaction__commit .side_effect = ZeroDivisionError
122+ Connection . begin .side_effect = ZeroDivisionError
123123 with pytest .raises (ZeroDivisionError ):
124124 async with bind .transaction ():
125125 pass
126126 assert init_size == qsize (bind )
127127
128128
129129async def test_reuse (bind ):
130- from asyncpg . transaction import Transaction
130+ from aiomysql . connection import Connection
131131
132132 init_size = qsize (bind )
133133 async with db .acquire () as conn :
134134 async with db .transaction () as tx :
135135 assert tx .connection .raw_connection is conn .raw_connection
136- assert isinstance (tx .raw_transaction , Transaction )
136+ assert isinstance (tx .raw_transaction , Connection )
137137 async with db .transaction () as tx2 :
138138 assert tx2 .connection .raw_connection is conn .raw_connection
139139 async with db .transaction (reuse = False ) as tx2 :
@@ -256,7 +256,7 @@ async def test_base_exception(engine):
256256
257257
258258async def test_no_rollback_on_commit_fail (engine , mocker ):
259- mocker .patch ("asyncpg.transaction.Transaction .commit" ).side_effect = IndexError
259+ mocker .patch ("aiomysql.connection.Connection .commit" ).side_effect = IndexError
260260 async with engine .acquire () as conn :
261261 tx = await conn .transaction ().__aenter__ ()
262262 rollback = mocker .patch .object (tx ._tx , "rollback" )
0 commit comments