Skip to content

Commit a5c76f7

Browse files
Add a test for function with comprehension or generator
1 parent 4e7b64c commit a5c76f7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/functional/l/len_checks.py

+9
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,14 @@ def function_returning_int(r):
158158
return 1
159159
return 2
160160

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+
161168
assert len(function_returning_list(z)) # [len-as-condition]
162169
assert len(function_returning_int(z))
170+
assert len(function_returning_generator(z)) # [len-as-condition]
171+
assert len(function_returning_comprehension(z)) # [len-as-condition]

tests/functional/l/len_checks.txt

+2
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)