Skip to content

Commit 3bfd075

Browse files
Add regression test for #3651 (#7117)
1 parent 7fdf8d9 commit 3bfd075

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/lint/unittest_lint.py

+32
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,38 @@ def test_recursive_ignore(ignore_parameter, ignore_parameter_value) -> None:
914914
assert module in linted_file_paths
915915

916916

917+
def test_relative_imports(initialized_linter: PyLinter) -> None:
918+
"""Regression test for https://github.com/PyCQA/pylint/issues/3651"""
919+
linter = initialized_linter
920+
with tempdir() as tmpdir:
921+
create_files(["x/y/__init__.py", "x/y/one.py", "x/y/two.py"], tmpdir)
922+
with open("x/y/__init__.py", "w", encoding="utf-8") as f:
923+
f.write(
924+
"""
925+
\"\"\"Module x.y\"\"\"
926+
from .one import ONE
927+
from .two import TWO
928+
"""
929+
)
930+
with open("x/y/one.py", "w", encoding="utf-8") as f:
931+
f.write(
932+
"""
933+
\"\"\"Module x.y.one\"\"\"
934+
ONE = 1
935+
"""
936+
)
937+
with open("x/y/two.py", "w", encoding="utf-8") as f:
938+
f.write(
939+
"""
940+
\"\"\"Module x.y.two\"\"\"
941+
from .one import ONE
942+
TWO = ONE + ONE
943+
"""
944+
)
945+
linter.check(["x/y"])
946+
assert not linter.stats.by_msg
947+
948+
917949
def test_import_sibling_module_from_namespace(initialized_linter: PyLinter) -> None:
918950
"""If the parent directory above `namespace` is on sys.path, ensure that
919951
modules under `namespace` can import each other without raising `import-error`."""

0 commit comments

Comments
 (0)