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

Method bad_awaitable

Lib/test/test_asyncgen.py:786–802  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

784
785 def test_anext_bad_await(self):
786 async def bad_awaitable():
787 class BadAwaitable:
788 def __await__(self):
789 return 42
790 class MyAsyncIter:
791 def __aiter__(self):
792 return self
793 def __anext__(self):
794 return BadAwaitable()
795 regex = r"__await__.*iterator"
796 awaitable = anext(MyAsyncIter(), "default")
797 with self.assertRaisesRegex(TypeError, regex):
798 await awaitable
799 awaitable = anext(MyAsyncIter())
800 with self.assertRaisesRegex(TypeError, regex):
801 await awaitable
802 return "completed"
803 result = self.loop.run_until_complete(bad_awaitable())
804 self.assertEqual(result, "completed")
805

Callers

nothing calls this directly

Calls 3

anextFunction · 0.85
MyAsyncIterClass · 0.85
assertRaisesRegexMethod · 0.80

Tested by

no test coverage detected