(self)
| 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 |
nothing calls this directly
no test coverage detected