Skip to content

Commit f10d286

Browse files
Add a test for function with comprehension or generator
Or a function returning a generator.
1 parent 3d14397 commit f10d286

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/functional/l/len_checks.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,18 @@ def function_returning_int(r):
158158
return 1
159159
return 2
160160

161-
assert len(function_returning_list(z)) # [len-as-condition]
161+
def function_returning_generator(r):
162+
for i in [r, 1, 2, 3]:
163+
yield i
164+
165+
def function_returning_comprehension(r):
166+
return [x+1 for x in [r, 1, 2, 3]]
167+
168+
def function_returning_function(r):
169+
return function_returning_generator(r)
170+
171+
assert len(function_returning_list(z)) # [len-as-condition]
162172
assert len(function_returning_int(z))
173+
assert len(function_returning_generator(z)) # [len-as-condition]
174+
assert len(function_returning_comprehension(z)) # [len-as-condition]
175+
assert len(function_returning_function(z)) # [len-as-condition]

tests/functional/l/len_checks.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ len-as-condition:129:github_issue_1879:Do not use `len(SEQUENCE)` without compar
2222
len-as-condition:130:github_issue_1879:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty
2323
len-as-condition:131:github_issue_1879:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty
2424
len-as-condition:161:github_issue_1879:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty
25+
len-as-condition:170:github_issue_1879:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty
26+
len-as-condition:171:github_issue_1879:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty

0 commit comments

Comments
 (0)