MCPcopy Index your code
hub / github.com/python/cpython / test_cancel_task_ignoring

Method test_cancel_task_ignoring

Lib/test/test_asyncio/test_tasks.py:927–955  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

925 self.assertFalse(t.cancelled())
926
927 def test_cancel_task_ignoring(self):
928 fut1 = self.new_future(self.loop)
929 fut2 = self.new_future(self.loop)
930 fut3 = self.new_future(self.loop)
931
932 async def task():
933 await fut1
934 try:
935 await fut2
936 except asyncio.CancelledError:
937 pass
938 res = await fut3
939 return res
940
941 t = self.new_task(self.loop, task())
942 test_utils.run_briefly(self.loop)
943 self.assertIs(t._fut_waiter, fut1) # White-box test.
944 fut1.set_result(None)
945 test_utils.run_briefly(self.loop)
946 self.assertIs(t._fut_waiter, fut2) # White-box test.
947 t.cancel()
948 self.assertTrue(fut2.cancelled())
949 test_utils.run_briefly(self.loop)
950 self.assertIs(t._fut_waiter, fut3) # White-box test.
951 fut3.set_result(42)
952 res = self.loop.run_until_complete(t)
953 self.assertEqual(res, 42)
954 self.assertFalse(fut3.cancelled())
955 self.assertFalse(t.cancelled())
956
957 def test_cancel_current_task(self):
958 loop = asyncio.new_event_loop()

Callers

nothing calls this directly

Calls 12

new_futureMethod · 0.95
new_taskMethod · 0.95
taskFunction · 0.85
run_brieflyMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertIsMethod · 0.45
set_resultMethod · 0.45
cancelMethod · 0.45
cancelledMethod · 0.45
run_until_completeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected