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

Method test_async_gen_exception_12

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

Source from the content-addressed store, hash-verified

378 self.compare_generators(sync_gen_wrapper(), async_gen_wrapper())
379
380 def test_async_gen_exception_12(self):
381 async def gen():
382 with self.assertWarnsRegex(RuntimeWarning,
383 f"coroutine method 'asend' of '{gen.__qualname__}' "
384 f"was never awaited"):
385 await anext(me)
386 yield 123
387
388 me = gen()
389 ai = me.__aiter__()
390 an = ai.__anext__()
391
392 with self.assertRaisesRegex(RuntimeError,
393 r'anext\(\): asynchronous generator is already running'):
394 an.__next__()
395
396 with self.assertRaisesRegex(RuntimeError,
397 r"cannot reuse already awaited __anext__\(\)/asend\(\)"):
398 an.send(None)
399
400 def test_async_gen_asend_throw_concurrent_with_send(self):
401 import types

Callers

nothing calls this directly

Calls 6

assertRaisesRegexMethod · 0.80
genFunction · 0.70
__aiter__Method · 0.45
__anext__Method · 0.45
__next__Method · 0.45
sendMethod · 0.45

Tested by

no test coverage detected