summaryrefslogtreecommitdiff
path: root/tests/checkers/unittest_imports.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/checkers/unittest_imports.py')
-rw-r--r--tests/checkers/unittest_imports.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/checkers/unittest_imports.py b/tests/checkers/unittest_imports.py
index 8d5af7d3f..8f03e5f49 100644
--- a/tests/checkers/unittest_imports.py
+++ b/tests/checkers/unittest_imports.py
@@ -23,6 +23,7 @@ import os
import astroid
+from pylint import epylint as lint
from pylint.checkers import imports
from pylint.interfaces import UNDEFINED
from pylint.testutils import CheckerTestCase, MessageTest, set_config
@@ -144,6 +145,38 @@ class TestImportsChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_importfrom(module.body[2].body[0])
+ @staticmethod
+ def test_relative_beyond_top_level_two() -> None:
+ output, errors = lint.py_run(
+ f"{os.path.join(REGR_DATA, 'beyond_top_two')} -d all -e relative-beyond-top-level",
+ return_std=True,
+ )
+ output2, errors2 = lint.py_run(
+ f"{os.path.join(REGR_DATA, 'beyond_top_two/namespace_package/top_level_function.py')} -d all -e relative-beyond-top-level",
+ return_std=True,
+ )
+
+ assert len(output.readlines()) == len(output2.readlines())
+ assert errors.readlines() == errors2.readlines()
+
+ @staticmethod
+ def test_relative_beyond_top_level_three() -> None:
+ output, errors = lint.py_run(
+ f"{os.path.join(REGR_DATA, 'beyond_top_three/a.py')} -d all -e relative-beyond-top-level",
+ return_std=True,
+ )
+ assert len(output.readlines()) == 5
+ assert errors.readlines() == []
+
+ @staticmethod
+ def test_relative_beyond_top_level_four() -> None:
+ output, errors = lint.py_run(
+ f"{os.path.join(REGR_DATA, 'beyond_top_four/module')} -d missing-docstring,unused-import",
+ return_std=True,
+ )
+ assert len(output.readlines()) == 5
+ assert errors.readlines() == []
+
def test_wildcard_import_init(self) -> None:
module = astroid.MANAGER.ast_from_module_name("init_wildcard", REGR_DATA)
import_from = module.body[0]