Skip to content

Commit 96f17a8

Browse files
committed
improve new tests
1 parent 9f814a4 commit 96f17a8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Lib/test/test_listcomps.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -385,25 +385,25 @@ def test_global_outside_cellvar_inside_plus_freevar(self):
385385
code = """
386386
a = 1
387387
def f():
388-
[(lambda: b) for b in [a]]
389-
return b
388+
func, = [(lambda: b) for b in [a]]
389+
return b, func()
390390
x = f()
391391
"""
392392
self._check_in_scopes(
393-
code, {"x": 2}, ns={"b": 2}, scopes=["function", "module"])
393+
code, {"x": (2, 1)}, ns={"b": 2}, scopes=["function", "module"])
394394
# inside a class, the `a = 1` assignment is not visible
395395
self._check_in_scopes(code, raises=NameError, scopes=["class"])
396396

397397
def test_cell_in_nested_comprehension(self):
398398
code = """
399399
a = 1
400400
def f():
401-
[[lambda: b for b in c] + [b] for c in [[a]]]
402-
return b
401+
(func, inner_b), = [[lambda: b for b in c] + [b] for c in [[a]]]
402+
return b, inner_b, func()
403403
x = f()
404404
"""
405405
self._check_in_scopes(
406-
code, {"x": 2}, ns={"b": 2}, scopes=["function", "module"])
406+
code, {"x": (2, 2, 1)}, ns={"b": 2}, scopes=["function", "module"])
407407
# inside a class, the `a = 1` assignment is not visible
408408
self._check_in_scopes(code, raises=NameError, scopes=["class"])
409409

0 commit comments

Comments
 (0)