mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
bpo-33041: Fixed jumping if the function contains an "async for" loop. (GH-6154)
This commit is contained in:
parent
c71edab15d
commit
b9744e924c
4 changed files with 103 additions and 27 deletions
|
@ -1846,6 +1846,36 @@ class CoroutineTest(unittest.TestCase):
|
|||
run_async(run_gen()),
|
||||
([], [121]))
|
||||
|
||||
def test_comp_4_2(self):
|
||||
async def f(it):
|
||||
for i in it:
|
||||
yield i
|
||||
|
||||
async def run_list():
|
||||
return [i + 10 async for i in f(range(5)) if 0 < i < 4]
|
||||
self.assertEqual(
|
||||
run_async(run_list()),
|
||||
([], [11, 12, 13]))
|
||||
|
||||
async def run_set():
|
||||
return {i + 10 async for i in f(range(5)) if 0 < i < 4}
|
||||
self.assertEqual(
|
||||
run_async(run_set()),
|
||||
([], {11, 12, 13}))
|
||||
|
||||
async def run_dict():
|
||||
return {i + 10: i + 100 async for i in f(range(5)) if 0 < i < 4}
|
||||
self.assertEqual(
|
||||
run_async(run_dict()),
|
||||
([], {11: 101, 12: 102, 13: 103}))
|
||||
|
||||
async def run_gen():
|
||||
gen = (i + 10 async for i in f(range(5)) if 0 < i < 4)
|
||||
return [g + 100 async for g in gen]
|
||||
self.assertEqual(
|
||||
run_async(run_gen()),
|
||||
([], [111, 112, 113]))
|
||||
|
||||
def test_comp_5(self):
|
||||
async def f(it):
|
||||
for i in it:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue