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

Method test_async_gen_exception_04

Lib/test/test_asyncgen.py:230–249  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

228 to_list(gen())
229
230 def test_async_gen_exception_04(self):
231 async def gen():
232 await awaitable()
233 yield 123
234 1 / 0
235
236 g = gen()
237 ai = g.__aiter__()
238 an = ai.__anext__()
239 self.assertEqual(an.__next__(), ('result',))
240
241 try:
242 an.__next__()
243 except StopIteration as ex:
244 self.assertEqual(ex.args[0], 123)
245 else:
246 self.fail('StopIteration was not raised')
247
248 with self.assertRaises(ZeroDivisionError):
249 ai.__anext__().__next__()
250
251 def test_async_gen_exception_05(self):
252 async def gen():

Callers

nothing calls this directly

Calls 7

genFunction · 0.70
__aiter__Method · 0.45
__anext__Method · 0.45
assertEqualMethod · 0.45
__next__Method · 0.45
failMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected