summaryrefslogtreecommitdiff
path: root/pylint/test/test_self.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-12-01 14:58:59 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-12-01 14:58:59 +0200
commit60dc4441f52dcf9d3ffd78b37be304bdce84b87e (patch)
treede4b4e93c506b9edceb23d24695c6f0a7b353c3b /pylint/test/test_self.py
parent0b5ab33c81a753ad732bfa5cdcf933bb2167a12c (diff)
downloadpylint-60dc4441f52dcf9d3ffd78b37be304bdce84b87e.tar.gz
Don't emit import-self and cyclic-import for relative imports of modules with the same name as the package itself.
The problem was partially the fault of astroid.modutils.get_module_part, in combination with a given context file. The function returned 'dummy' as the module part for the string `dummy.dummy.Dummy`, which is in fact true, since the first dummy is the package and the second dummy is the module from where Dummy gets loaded. But get_module_part has no way to know this semantic inference, that the second dummy is a relative import inside the first one. As such, it's better to just skip the check if the condition of being relative inside a __init__.py file is found, since there's no way to load itself in that case. Closes issues #708 and #706.
Diffstat (limited to 'pylint/test/test_self.py')
-rw-r--r--pylint/test/test_self.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py
index 69b739c..fae6403 100644
--- a/pylint/test/test_self.py
+++ b/pylint/test/test_self.py
@@ -288,7 +288,12 @@ class RunTC(unittest.TestCase):
actual_output = out.getvalue()
self.assertEqual(expected_output.strip(), actual_output.strip())
-
+ def test_import_itself_not_accounted_for_relative_imports(self):
+ expected = 'No config file found, using default configuration'
+ package = join(HERE, 'regrtest_data', 'dummy')
+ self._test_output([package, '--disable=locally-disabled', '-rn'],
+ expected_output=expected)
+
if __name__ == '__main__':