(self)
| 1243 | self.assertIsNone(b.result()) |
| 1244 | |
| 1245 | def test_wait_first_exception(self): |
| 1246 | |
| 1247 | def gen(): |
| 1248 | when = yield |
| 1249 | self.assertAlmostEqual(10.0, when) |
| 1250 | yield 0 |
| 1251 | |
| 1252 | loop = self.new_test_loop(gen) |
| 1253 | |
| 1254 | # first_exception, task already has exception |
| 1255 | a = self.new_task(loop, asyncio.sleep(10.0)) |
| 1256 | |
| 1257 | async def exc(): |
| 1258 | raise ZeroDivisionError('err') |
| 1259 | |
| 1260 | b = self.new_task(loop, exc()) |
| 1261 | task = self.new_task( |
| 1262 | loop, |
| 1263 | asyncio.wait([b, a], return_when=asyncio.FIRST_EXCEPTION)) |
| 1264 | |
| 1265 | done, pending = loop.run_until_complete(task) |
| 1266 | self.assertEqual({b}, done) |
| 1267 | self.assertEqual({a}, pending) |
| 1268 | self.assertAlmostEqual(0, loop.time()) |
| 1269 | |
| 1270 | # move forward to close generator |
| 1271 | loop.advance_time(10) |
| 1272 | loop.run_until_complete(asyncio.wait([a, b])) |
| 1273 | |
| 1274 | def test_wait_first_exception_in_wait(self): |
| 1275 |
nothing calls this directly
no test coverage detected