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

Method test_reschedule

Lib/test/test_asyncio/test_timeouts.py:228–252  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

226 self.assertTrue(t0 <= t1 <= t0 + 1)
227
228 async def test_reschedule(self):
229 loop = asyncio.get_running_loop()
230 fut = loop.create_future()
231 deadline1 = loop.time() + 10
232 deadline2 = deadline1 + 20
233
234 async def f():
235 async with asyncio.timeout_at(deadline1) as cm:
236 fut.set_result(cm)
237 await asyncio.sleep(50)
238
239 task = asyncio.create_task(f())
240 cm = await fut
241
242 self.assertEqual(cm.when(), deadline1)
243 cm.reschedule(deadline2)
244 self.assertEqual(cm.when(), deadline2)
245 cm.reschedule(None)
246 self.assertIsNone(cm.when())
247
248 task.cancel()
249
250 with self.assertRaises(asyncio.CancelledError):
251 await task
252 self.assertFalse(cm.expired())
253
254 async def test_repr_active(self):
255 async with asyncio.timeout(10) as cm:

Callers

nothing calls this directly

Calls 12

rescheduleMethod · 0.80
assertIsNoneMethod · 0.80
assertFalseMethod · 0.80
expiredMethod · 0.80
fFunction · 0.50
create_futureMethod · 0.45
timeMethod · 0.45
create_taskMethod · 0.45
assertEqualMethod · 0.45
whenMethod · 0.45
cancelMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected