File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -551,6 +551,54 @@ async def gen():
551
551
self .assertTrue (inspect .isawaitable (aclose ))
552
552
aclose .close ()
553
553
554
+ def test_async_gen_asend_close_runtime_error (self ):
555
+ import types
556
+
557
+ @types .coroutine
558
+ def _async_yield (v ):
559
+ return (yield v )
560
+
561
+ async def agenfn ():
562
+ try :
563
+ await _async_yield (None )
564
+ except GeneratorExit :
565
+ await _async_yield (None )
566
+ return
567
+ yield
568
+
569
+ agen = agenfn ()
570
+ gen = agen .asend (None )
571
+ gen .send (None )
572
+ with self .assertRaisesRegex (RuntimeError , "coroutine ignored GeneratorExit" ):
573
+ gen .close ()
574
+
575
+ def test_async_gen_athrow_close_runtime_error (self ):
576
+ import types
577
+
578
+ @types .coroutine
579
+ def _async_yield (v ):
580
+ return (yield v )
581
+
582
+ class MyExc (Exception ):
583
+ pass
584
+
585
+ async def agenfn ():
586
+ try :
587
+ yield
588
+ except MyExc :
589
+ try :
590
+ await _async_yield (None )
591
+ except GeneratorExit :
592
+ await _async_yield (None )
593
+
594
+ agen = agenfn ()
595
+ with self .assertRaises (StopIteration ):
596
+ agen .asend (None ).send (None )
597
+ gen = agen .athrow (MyExc )
598
+ gen .send (None )
599
+ with self .assertRaisesRegex (RuntimeError , "coroutine ignored GeneratorExit" ):
600
+ gen .close ()
601
+
554
602
555
603
class AsyncGenAsyncioTest (unittest .TestCase ):
556
604
You can’t perform that action at this time.
0 commit comments