diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-04-18 09:11:12 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-04-18 09:12:29 +0200 |
commit | deae2ae1eb7650d6d2c37e70a488361043fcba96 (patch) | |
tree | dc5357fdfca72b6d7e1375cb0a150068a30f4657 /pylint/test/unittest_checker_python3.py | |
parent | decf303fdc18162f156e371254165bd008379498 (diff) | |
download | pylint-git-deae2ae1eb7650d6d2c37e70a488361043fcba96.tar.gz |
Handle dict subclasses for dict-not-iterating checks
Diffstat (limited to 'pylint/test/unittest_checker_python3.py')
-rw-r--r-- | pylint/test/unittest_checker_python3.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/pylint/test/unittest_checker_python3.py b/pylint/test/unittest_checker_python3.py index f97d6e54c..12b82b0e3 100644 --- a/pylint/test/unittest_checker_python3.py +++ b/pylint/test/unittest_checker_python3.py @@ -181,17 +181,34 @@ class TestPython3Checker(testutils.CheckerTestCase): self.as_argument_to_callable_constructor_test(fxn, func) @python2_only + def test_dict_subclasses_methods_in_iterating_context(self): + iterating, not_iterating = astroid.extract_node(''' + from __future__ import absolute_import + from collections import defaultdict + d = defaultdict(list) + a, b = d.keys() #@ + x = d.keys() #@ + ''') + + with self.assertNoMessages(): + self.checker.visit_call(iterating.value) + + message = testutils.Message('dict-keys-not-iterating', node=not_iterating.value) + with self.assertAddsMessages(message): + self.checker.visit_call(not_iterating.value) + + @python2_only def test_dict_methods_in_iterating_context(self): iterating_code = [ 'for x in {}: pass', '(x for x in {})', '[x for x in {}]', 'func({})', - 'a, b = {}' + 'a, b = {}', ] non_iterating_code = [ 'x = __({}())', - '__({}())[0]' + '__({}())[0]', ] for method in ('keys', 'items', 'values'): |