@@ -379,7 +379,10 @@ async def async_gen_wrapper():
379
379
380
380
def test_async_gen_exception_12 (self ):
381
381
async def gen ():
382
- await anext (me )
382
+ with self .assertWarnsRegex (RuntimeWarning ,
383
+ f"coroutine method 'asend' of '{ gen .__qualname__ } ' "
384
+ f"was never awaited" ):
385
+ await anext (me )
383
386
yield 123
384
387
385
388
me = gen ()
@@ -395,7 +398,12 @@ async def gen():
395
398
yield 123
396
399
397
400
with self .assertWarns (DeprecationWarning ):
398
- gen ().athrow (GeneratorExit , GeneratorExit (), None )
401
+ x = gen ().athrow (GeneratorExit , GeneratorExit (), None )
402
+ with self .assertWarnsRegex (RuntimeWarning ,
403
+ f"coroutine method 'athrow' of '{ gen .__qualname__ } ' "
404
+ f"was never awaited" ):
405
+ del x
406
+ gc_collect ()
399
407
400
408
def test_async_gen_api_01 (self ):
401
409
async def gen ():
@@ -1564,6 +1572,11 @@ async def main():
1564
1572
self .assertIsInstance (message ['exception' ], ZeroDivisionError )
1565
1573
self .assertIn ('unhandled exception during asyncio.run() shutdown' ,
1566
1574
message ['message' ])
1575
+ with self .assertWarnsRegex (RuntimeWarning ,
1576
+ f"coroutine method 'aclose' of '{ async_iterate .__qualname__ } ' "
1577
+ f"was never awaited" ):
1578
+ del message , messages
1579
+ gc_collect ()
1567
1580
1568
1581
def test_async_gen_expression_01 (self ):
1569
1582
async def arange (n ):
@@ -1617,6 +1630,10 @@ async def main():
1617
1630
asyncio .run (main ())
1618
1631
1619
1632
self .assertEqual ([], messages )
1633
+ with self .assertWarnsRegex (RuntimeWarning ,
1634
+ f"coroutine method 'aclose' of '{ async_iterate .__qualname__ } ' "
1635
+ f"was never awaited" ):
1636
+ gc_collect ()
1620
1637
1621
1638
def test_async_gen_await_same_anext_coro_twice (self ):
1622
1639
async def async_iterate ():
0 commit comments