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

Method test_wait_first_exception

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected