summaryrefslogtreecommitdiff
path: root/pylint/test
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-03-11 17:56:56 +0000
committerClaudiu Popa <pcmanticore@gmail.com>2016-03-11 17:56:56 +0000
commit9e7bee05d62e682c8199f64c9ae3d787fd5c0072 (patch)
treee42fd50755995f8746b011345ae4f4a596dca764 /pylint/test
parent9f128369b94df988c9eb0bc67184ab90fe535553 (diff)
downloadpylint-git-9e7bee05d62e682c8199f64c9ae3d787fd5c0072.tar.gz
Ignore __all__ elements that don't have a parent
There used to be a bug which involved astroid and extension modules, where the elements of the __all__ declaration didn't have a parent set. This problem was fixed though in astroid 2.0 and we can infer properly these declarations with the parent being set. Unfortunately, we can't rely on astroid 2.0 right now, so the solution for not having crashes is to skip these elements in the undefined-all-variable pattern. Close #846
Diffstat (limited to 'pylint/test')
-rw-r--r--pylint/test/unittest_checker_variables.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/pylint/test/unittest_checker_variables.py b/pylint/test/unittest_checker_variables.py
index 0a235d4b2..e42dffcfd 100644
--- a/pylint/test/unittest_checker_variables.py
+++ b/pylint/test/unittest_checker_variables.py
@@ -38,6 +38,14 @@ class VariablesCheckerTC(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_importfrom(node)
+ def test_all_elements_without_parent(self):
+ node = test_utils.extract_node('__all__ = []')
+ node.value.elts.append(astroid.Const('test'))
+ root = node.root()
+ with self.assertNoMessages():
+ self.checker.visit_module(root)
+ self.checker.leave_module(root)
+
@set_config(callbacks=('callback_', '_callback'))
def test_custom_callback_string(self):
""" Test the --calbacks option works. """