MCPcopy Index your code
hub / github.com/RustPython/RustPython / test5

Method test5

Lib/test/test_asyncgen.py:920–937  ·  view source on GitHub ↗
(anext)

Source from the content-addressed store, hash-verified

918 g.throw(MyError('val'))
919
920 def test5(anext):
921 @types.coroutine
922 def _async_yield(v):
923 yield v * 10
924 return (yield (v * 10 + 1))
925
926 async def agenfn():
927 try:
928 await _async_yield(1)
929 except MyError:
930 return
931 yield 'aaa'
932
933 agen = agenfn()
934 with contextlib.closing(anext(agen, "default").__await__()) as g:
935 self.assertEqual(g.send(None), 10)
936 with self.assertRaisesRegex(StopIteration, 'default'):
937 g.throw(MyError())
938
939 def test6(anext):
940 @types.coroutine

Callers

nothing calls this directly

Calls 8

anextFunction · 0.85
closingMethod · 0.80
assertRaisesRegexMethod · 0.80
MyErrorClass · 0.70
__await__Method · 0.45
assertEqualMethod · 0.45
sendMethod · 0.45
throwMethod · 0.45

Tested by

no test coverage detected