Skip to content

Commit 549cd11

Browse files
Test for async generator is added
1 parent 75e6184 commit 549cd11

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Lib/test/test_coroutines.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ def c():
22672267

22682268
def test_call_aiter_once_in_comprehension(self):
22692269

2270-
class Iterator:
2270+
class AsyncIterator:
22712271

22722272
def __init__(self):
22732273
self.val = 0
@@ -2283,12 +2283,17 @@ async def __anext__(self):
22832283
class C:
22842284

22852285
def __aiter__(self):
2286-
return Iterator()
2286+
return AsyncIterator()
22872287

2288-
async def run():
2288+
async def run_listcomp():
22892289
return [i async for i in C()]
22902290

2291-
self.assertEqual(run_async(run()), ([], [1,2]))
2291+
async def run_asyncgen():
2292+
ag = (i async for i in C())
2293+
return [i async for i in ag]
2294+
2295+
self.assertEqual(run_async(run_listcomp()), ([], [1, 2]))
2296+
self.assertEqual(run_async(run_asyncgen()), ([], [1, 2]))
22922297

22932298

22942299
@unittest.skipIf(

Lib/test/test_generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class C:
288288
def __iter__(self):
289289
return Iterator()
290290

291-
self.assertEqual([1,2], list(i for i in C()))
291+
self.assertEqual([1, 2], list(i for i in C()))
292292

293293

294294
class ModifyUnderlyingIterableTest(unittest.TestCase):

Lib/test/test_listcomps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ class C:
770770
def __iter__(self):
771771
return Iterator()
772772

773-
self.assertEqual([1,2], [i for i in C()])
773+
self.assertEqual([1, 2], [i for i in C()])
774774

775775
__test__ = {'doctests' : doctests}
776776

0 commit comments

Comments
 (0)