Skip to content
Prev Previous commit
A few more tests
  • Loading branch information
JelleZijlstra committed May 18, 2023
commit afe0277eafb49307d3b19949ec954b8b59c67b2d
14 changes: 14 additions & 0 deletions Lib/test/test_listcomps.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,20 @@ def test_nested_free_var_in_iter(self):
"""
self._check_in_scopes(code, {"items": [1]})

def test_nested_free_var_in_expr(self):
code = """
items = [(_C, [x for x in [1] if _C]) for _C in [0, 1]]
"""
self._check_in_scopes(code, {"items": [(0, []), (1, [1])]})

def test_nested_listcomp_in_lambda(self):
code = """
f = [(z, lambda y: [(x, y, z) for x in [3]]) for z in [1]]
(z, func), = f
out = func(2)
"""
self._check_in_scopes(code, {"z": 1, "out": [(3, 2, 1)]})


__test__ = {'doctests' : doctests}

Expand Down