@@ -353,32 +353,28 @@ async def test_pool_release_in_xact(self):
353353 """Test that Connection.reset() closes any open transaction.""" 
354354 async  with  self .create_pool (database = 'postgres' ,
355355 min_size = 1 , max_size = 1 ) as  pool :
356- 
357-  last_error_ctx  =  None 
358- 
359356 async  def  get_xact_id (con ):
360357 return  await  con .fetchval ('select txid_current()' )
361358
362-  def  logger (loop , ctx ):
363-  nonlocal  last_error_ctx 
364-  last_error_ctx  =  ctx 
365- 
366-  async  with  pool .acquire () as  con :
367-  id1  =  await  get_xact_id (con )
359+  with  self .assertLoopErrorHandlerCalled ('an active transaction' ):
360+  async  with  pool .acquire () as  con :
361+  real_con  =  con ._con  # unwrap PoolConnectionProxy 
368362
369-  tr  =  con .transaction ()
370-  await  tr .start ()
363+  id1  =  await  get_xact_id (con )
371364
372-  id2  =  await  get_xact_id (con )
373-  self .assertNotEqual (id1 , id2 )
365+  tr  =  con .transaction ()
366+  self .assertIsNone (con ._con ._top_xact )
367+  await  tr .start ()
368+  self .assertIs (real_con ._top_xact , tr )
374369
375-  self .loop .set_exception_handler (logger )
370+  id2  =  await  get_xact_id (con )
371+  self .assertNotEqual (id1 , id2 )
376372
377-  self .assertIsNotNone (last_error_ctx )
378-  self .assertIn ('an active transaction' , last_error_ctx ['message' ])
379-  self .loop .set_exception_handler (None )
373+  self .assertIsNone (real_con ._top_xact )
380374
381375 async  with  pool .acquire () as  con :
376+  self .assertIs (con ._con , real_con )
377+  self .assertIsNone (con ._con ._top_xact )
382378 id3  =  await  get_xact_id (con )
383379 self .assertNotEqual (id2 , id3 )
384380
0 commit comments