Skip to content

Commit b58bdc9

Browse files
committed
Uncomment async for tests
1 parent f3501f4 commit b58bdc9

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

‎Lib/test/test_asyncgen.py‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,15 @@ def __anext__(self):
513513
return self.yielded
514514
self.check_async_iterator_anext(MyAsyncIterWithTypesCoro)
515515

516-
# TODO: RUSTPYTHON: async for gen expression compilation
517-
# def test_async_gen_aiter(self):
518-
# async def gen():
519-
# yield 1
520-
# yield 2
521-
# g = gen()
522-
# async def consume():
523-
# return [i async for i in aiter(g)]
524-
# res = self.loop.run_until_complete(consume())
525-
# self.assertEqual(res, [1, 2])
516+
def test_async_gen_aiter(self):
517+
async def gen():
518+
yield 1
519+
yield 2
520+
g = gen()
521+
async def consume():
522+
return [i async for i in aiter(g)]
523+
res = self.loop.run_until_complete(consume())
524+
self.assertEqual(res, [1, 2])
526525

527526
# TODO: RUSTPYTHON, NameError: name 'aiter' is not defined
528527
@unittest.expectedFailure
@@ -1569,22 +1568,23 @@ async def main():
15691568
self.assertIn('unhandled exception during asyncio.run() shutdown',
15701569
message['message'])
15711570

1572-
# TODO: RUSTPYTHON: async for gen expression compilation
1573-
# def test_async_gen_expression_01(self):
1574-
# async def arange(n):
1575-
# for i in range(n):
1576-
# await asyncio.sleep(0.01)
1577-
# yield i
1571+
# TODO: RUSTPYTHON; TypeError: object async_generator can't be used in 'await' expression
1572+
@unittest.expectedFailure
1573+
def test_async_gen_expression_01(self):
1574+
async def arange(n):
1575+
for i in range(n):
1576+
await asyncio.sleep(0.01)
1577+
yield i
15781578

1579-
# def make_arange(n):
1580-
# # This syntax is legal starting with Python 3.7
1581-
# return (i * 2 async for i in arange(n))
1579+
def make_arange(n):
1580+
# This syntax is legal starting with Python 3.7
1581+
return (i * 2 async for i in arange(n))
15821582

1583-
# async def run():
1584-
# return [i async for i in make_arange(10)]
1583+
async def run():
1584+
return [i async for i in make_arange(10)]
15851585

1586-
# res = self.loop.run_until_complete(run())
1587-
# self.assertEqual(res, [i * 2 for i in range(10)])
1586+
res = self.loop.run_until_complete(run())
1587+
self.assertEqual(res, [i * 2 for i in range(10)])
15881588

15891589
# TODO: RUSTPYTHON: async for gen expression compilation
15901590
# def test_async_gen_expression_02(self):

0 commit comments

Comments
 (0)