X Tutup
Skip to content

Commit 64cb090

Browse files
committed
added test for builtin.aiter
1 parent a6d9047 commit 64cb090

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Lib/test/test_asyncgen.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,29 @@ def tearDown(self):
374374
self.loop = None
375375
asyncio.set_event_loop_policy(None)
376376

377+
def test_aiter_idempotent(self):
378+
async def gen():
379+
yield 1
380+
applied_once = aiter(gen())
381+
applied_twice = aiter(applied_once)
382+
self.assertIs(applied_once, applied_twice)
383+
384+
def test_aiter_bad_args(self):
385+
async def gen():
386+
yield 1
387+
async def call_with_too_few_args():
388+
await aiter()
389+
async def call_with_too_many_args():
390+
await aiter(gen(), 1)
391+
async def call_with_wrong_type_arg():
392+
await aiter(1)
393+
with self.assertRaises(TypeError):
394+
self.loop.run_until_complete(call_with_too_few_args())
395+
with self.assertRaises(TypeError):
396+
self.loop.run_until_complete(call_with_too_many_args())
397+
with self.assertRaises(TypeError):
398+
self.loop.run_until_complete(call_with_wrong_type_arg())
399+
377400
async def to_list(self, gen):
378401
res = []
379402
async for i in gen:

0 commit comments

Comments
 (0)
X Tutup