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 @@ -571,6 +571,54 @@ async def gen():
571
571
self .assertTrue (inspect .isawaitable (aclose ))
572
572
aclose .close ()
573
573
574
+ def test_async_gen_asend_close_runtime_error (self ):
575
+ import types
576
+
577
+ @types .coroutine
578
+ def _async_yield (v ):
579
+ return (yield v )
580
+
581
+ async def agenfn ():
582
+ try :
583
+ await _async_yield (None )
584
+ except GeneratorExit :
585
+ await _async_yield (None )
586
+ return
587
+ yield
588
+
589
+ agen = agenfn ()
590
+ gen = agen .asend (None )
591
+ gen .send (None )
592
+ with self .assertRaisesRegex (RuntimeError , "coroutine ignored GeneratorExit" ):
593
+ gen .close ()
594
+
595
+ def test_async_gen_athrow_close_runtime_error (self ):
596
+ import types
597
+
598
+ @types .coroutine
599
+ def _async_yield (v ):
600
+ return (yield v )
601
+
602
+ class MyExc (Exception ):
603
+ pass
604
+
605
+ async def agenfn ():
606
+ try :
607
+ yield
608
+ except MyExc :
609
+ try :
610
+ await _async_yield (None )
611
+ except GeneratorExit :
612
+ await _async_yield (None )
613
+
614
+ agen = agenfn ()
615
+ with self .assertRaises (StopIteration ):
616
+ agen .asend (None ).send (None )
617
+ gen = agen .athrow (MyExc )
618
+ gen .send (None )
619
+ with self .assertRaisesRegex (RuntimeError , "coroutine ignored GeneratorExit" ):
620
+ gen .close ()
621
+
574
622
575
623
class AsyncGenAsyncioTest (unittest .TestCase ):
576
624
You can’t perform that action at this time.
0 commit comments