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

Method test_wait_with_timeout

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

Source from the content-addressed store, hash-verified

1334 self.assertAlmostEqual(0.15, loop.time())
1335
1336 def test_wait_with_timeout(self):
1337
1338 def gen():
1339 when = yield
1340 self.assertAlmostEqual(0.1, when)
1341 when = yield 0
1342 self.assertAlmostEqual(0.15, when)
1343 when = yield 0
1344 self.assertAlmostEqual(0.11, when)
1345 yield 0.11
1346
1347 loop = self.new_test_loop(gen)
1348
1349 a = self.new_task(loop, asyncio.sleep(0.1))
1350 b = self.new_task(loop, asyncio.sleep(0.15))
1351
1352 async def foo():
1353 done, pending = await asyncio.wait([b, a], timeout=0.11)
1354 self.assertEqual(done, set([a]))
1355 self.assertEqual(pending, set([b]))
1356
1357 loop.run_until_complete(self.new_task(loop, foo()))
1358 self.assertAlmostEqual(0.11, loop.time())
1359
1360 # move forward to close generator
1361 loop.advance_time(10)
1362 loop.run_until_complete(asyncio.wait([a, b]))
1363
1364 def test_wait_concurrent_complete(self):
1365

Callers

nothing calls this directly

Calls 9

new_taskMethod · 0.95
new_test_loopMethod · 0.80
advance_timeMethod · 0.80
fooFunction · 0.50
sleepMethod · 0.45
run_until_completeMethod · 0.45
assertAlmostEqualMethod · 0.45
timeMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected