File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -587,6 +587,24 @@ def task():
587
587
self .assertFalse (t ._must_cancel ) # White-box test.
588
588
self .assertFalse (t .cancel ())
589
589
590
+ def test_cancel_at_end (self ):
591
+ """coroutine end right after task is cancelled"""
592
+ loop = asyncio .new_event_loop ()
593
+ self .set_event_loop (loop )
594
+
595
+ @asyncio .coroutine
596
+ def task ():
597
+ t .cancel ()
598
+ self .assertTrue (t ._must_cancel ) # White-box test.
599
+ return 12
600
+
601
+ t = self .new_task (loop , task ())
602
+ self .assertRaises (
603
+ asyncio .CancelledError , loop .run_until_complete , t )
604
+ self .assertTrue (t .done ())
605
+ self .assertFalse (t ._must_cancel ) # White-box test.
606
+ self .assertFalse (t .cancel ())
607
+
590
608
def test_stop_while_run_in_complete (self ):
591
609
592
610
def gen ():
You can’t perform that action at this time.
0 commit comments