coroutine end right after task is cancelled
(self)
| 975 | self.assertFalse(t.cancel()) |
| 976 | |
| 977 | def test_cancel_at_end(self): |
| 978 | """coroutine end right after task is cancelled""" |
| 979 | loop = asyncio.new_event_loop() |
| 980 | self.set_event_loop(loop) |
| 981 | |
| 982 | async def task(): |
| 983 | t.cancel() |
| 984 | self.assertTrue(t._must_cancel) # White-box test. |
| 985 | return 12 |
| 986 | |
| 987 | t = self.new_task(loop, task()) |
| 988 | self.assertFalse(t.cancelled()) |
| 989 | self.assertRaises( |
| 990 | asyncio.CancelledError, loop.run_until_complete, t) |
| 991 | self.assertTrue(t.done()) |
| 992 | self.assertTrue(t.cancelled()) |
| 993 | self.assertFalse(t._must_cancel) # White-box test. |
| 994 | self.assertFalse(t.cancel()) |
| 995 | |
| 996 | def test_cancel_awaited_task(self): |
| 997 | # This tests for a relatively rare condition when |
nothing calls this directly
no test coverage detected