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

Method test_anext_await_raises

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

Source from the content-addressed store, hash-verified

831 self.assertEqual(result, "completed")
832
833 def test_anext_await_raises(self):
834 class RaisingAwaitable:
835 def __await__(self):
836 raise ZeroDivisionError()
837 yield
838 class WithRaisingAwaitableAnext:
839 def __aiter__(self):
840 return self
841 def __anext__(self):
842 return RaisingAwaitable()
843 async def do_test():
844 awaitable = anext(WithRaisingAwaitableAnext())
845 with self.assertRaises(ZeroDivisionError):
846 await awaitable
847 awaitable = anext(WithRaisingAwaitableAnext(), "default")
848 with self.assertRaises(ZeroDivisionError):
849 await awaitable
850 return "completed"
851 result = self.loop.run_until_complete(do_test())
852 self.assertEqual(result, "completed")
853
854 def test_anext_iter(self):
855 @types.coroutine

Callers

nothing calls this directly

Calls 2

run_until_completeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected