Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 578ceee

Browse files
committed
Add simple test of list comprehension that uses a name that isn't
otherwise used in the same code block. (Not sure this is the right place, but there is no test_list_comprehensions.py.)
1 parent 2528b19 commit 578ceee

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/output/test_grammar

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ classdef
5555
[3, 4, 5]
5656
[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')]
5757
[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')]
58+
[0, 0, 0]
5859
good: got a SyntaxError as expected
5960
good: got a SyntaxError as expected
6061
[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')]

Lib/test/test_grammar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,12 @@ def meth3(self, a1, a2): pass
612612
print [x for x in nums if x > 2]
613613
print [(i, s) for i in nums for s in strs]
614614
print [(i, s) for i in nums for s in [f for f in strs if "n" in f]]
615+
616+
def test_in_func(l):
617+
return [None < x < 3 for x in l if x > 2]
618+
619+
print test_in_func(nums)
620+
615621
try:
616622
eval("[i, s for i in nums for s in strs]")
617623
print "FAIL: should have raised a SyntaxError!"

0 commit comments

Comments
 (0)