summaryrefslogtreecommitdiff
path: root/pylint/test/functional/using_constant_test.py
diff options
context:
space:
mode:
authorBenjamin Drung <benjamin.drung@profitbricks.com>2018-09-24 14:22:40 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-09-28 14:34:49 +0200
commitdafd4245fe75c77ce4c8cf6017b36280db7f8459 (patch)
tree5ca30a475146ec45510df23b5238df7fc07a24f1 /pylint/test/functional/using_constant_test.py
parent2d32ff3b9b17c4900a02e123ec9773f8b69f23a2 (diff)
downloadpylint-git-dafd4245fe75c77ce4c8cf6017b36280db7f8459.tar.gz
Fix TypeError in test_good_comprehension_checks
The following expression from test_good_comprehension_checks will fail to execute, because the list element from the range function has the type int and int has no len method: ``` >>> [data for data in range(100) if len(data)] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 1, in <listcomp> TypeError: object of type 'int' has no len() ``` Use the built-in `abs` method instead of the `len` method to make the test case a little bit more realistic.
Diffstat (limited to 'pylint/test/functional/using_constant_test.py')
-rw-r--r--pylint/test/functional/using_constant_test.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/pylint/test/functional/using_constant_test.py b/pylint/test/functional/using_constant_test.py
index 61b4f819a..8d3c2da9a 100644
--- a/pylint/test/functional/using_constant_test.py
+++ b/pylint/test/functional/using_constant_test.py
@@ -70,12 +70,12 @@ if 1 if 2 else 3: # [using-constant-test]
pass
def test_comprehensions():
- [data for data in range(100) if len] # [using-constant-test]
+ [data for data in range(100) if abs] # [using-constant-test]
[data for data in range(100) if 1] # [using-constant-test]
- (data for data in range(100) if len) # [using-constant-test]
+ (data for data in range(100) if abs) # [using-constant-test]
(data for data in range(100) if 1) # [using-constant-test]
- {data for data in range(100) if len} # [using-constant-test]
- {data: 1 for data in range(100) if len} # [using-constant-test]
+ {data for data in range(100) if abs} # [using-constant-test]
+ {data: 1 for data in range(100) if abs} # [using-constant-test]
@@ -132,10 +132,10 @@ def test(*args):
def test_good_comprehension_checks():
[data for data in range(100)]
[data for data in range(100) if data]
- [data for data in range(100) if len(data)]
+ [data for data in range(100) if abs(data)]
(data for data in range(100) if data)
- (data for data in range(100) if len(data))
+ (data for data in range(100) if abs(data))
{data for data in range(100) if data}
- {data for data in range(100) if len(data)}
+ {data for data in range(100) if abs(data)}
{data: 1 for data in range(100) if data}
{data: 1 for data in range(100)}