summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_coroutines.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-03-23 13:45:37 (GMT)
committerGitHub <noreply@github.com>2018-03-23 13:45:37 (GMT)
commit18d7edf32e6832a818621cb8cb3d144928eca232 (patch)
tree6d040cf457e599d03919aedd1682e937d2edcb16 /Lib/test/test_coroutines.py
parent560ea272b01acaa6c531cc7d94331b2ef0854be6 (diff)
downloadcpython-18d7edf32e6832a818621cb8cb3d144928eca232.zip
cpython-18d7edf32e6832a818621cb8cb3d144928eca232.tar.gz
cpython-18d7edf32e6832a818621cb8cb3d144928eca232.tar.bz2
[3.6] bpo-33041: Fixed jumping if the function contains an "async for" loop. (GH-6154). (GH-6199)
(cherry picked from commit b9744e924ca07ba7db977e5958b91cd8db565632)
Diffstat (limited to 'Lib/test/test_coroutines.py')
-rw-r--r--Lib/test/test_coroutines.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index 2b79a17..41126b6 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -1892,6 +1892,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: