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

Method test_async_gen_iteration_02

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

Source from the content-addressed store, hash-verified

189 self.assertEqual(to_list(gen()), [123, 456, 789])
190
191 def test_async_gen_iteration_02(self):
192 async def gen():
193 await awaitable()
194 yield 123
195 await awaitable()
196
197 g = gen()
198 ai = g.__aiter__()
199
200 an = ai.__anext__()
201 self.assertEqual(an.__next__(), ('result',))
202
203 try:
204 an.__next__()
205 except StopIteration as ex:
206 self.assertEqual(ex.args[0], 123)
207 else:
208 self.fail('StopIteration was not raised')
209
210 an = ai.__anext__()
211 self.assertEqual(an.__next__(), ('result',))
212
213 try:
214 an.__next__()
215 except StopAsyncIteration as ex:
216 self.assertFalse(ex.args)
217 else:
218 self.fail('StopAsyncIteration was not raised')
219
220 def test_async_gen_exception_03(self):
221 async def gen():

Callers

nothing calls this directly

Calls 7

assertFalseMethod · 0.80
genFunction · 0.70
__aiter__Method · 0.45
__anext__Method · 0.45
assertEqualMethod · 0.45
__next__Method · 0.45
failMethod · 0.45

Tested by

no test coverage detected