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

Method test4

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

Source from the content-addressed store, hash-verified

897 self.assertEqual(g.send(None), 1)
898
899 def test4(anext):
900 @types.coroutine
901 def _async_yield(v):
902 yield v * 10
903 return (yield (v * 10 + 1))
904
905 async def agenfn():
906 try:
907 await _async_yield(1)
908 except MyError:
909 await _async_yield(2)
910 return
911 yield
912
913 agen = agenfn()
914 with contextlib.closing(anext(agen, "default").__await__()) as g:
915 self.assertEqual(g.send(None), 10)
916 self.assertEqual(g.throw(MyError()), 20)
917 with self.assertRaisesRegex(MyError, 'val'):
918 g.throw(MyError('val'))
919
920 def test5(anext):
921 @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