diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2022-08-13 13:20:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 19:20:57 +0200 |
commit | 6f9c371c4f82281570869be2e4c609844bfd8c34 (patch) | |
tree | 355ae04c1a3b2121082ef8d61343ce4564905519 /tests/lint | |
parent | 93ee0a039de2d6aa99c4871b0b9d3db53fddf437 (diff) | |
download | pylint-git-6f9c371c4f82281570869be2e4c609844bfd8c34.tar.gz |
Revert "Fix the failure to lint modules contained under an identically named directory" (#7304)
This reverts commit 3ebb700aed88a427011c2e88705f66ec0b3830a4.
* Add regression test for namespace packages under directory on path
* Fix expected result in `test_relative_beyond_top_level_two`
Diffstat (limited to 'tests/lint')
-rw-r--r-- | tests/lint/unittest_lint.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py index 27a6ba92c..2f3a5c170 100644 --- a/tests/lint/unittest_lint.py +++ b/tests/lint/unittest_lint.py @@ -944,10 +944,13 @@ def test_lint_namespace_package_under_dir(initialized_linter: PyLinter) -> None: assert not linter.stats.by_msg -def test_identically_named_nested_module(initialized_linter: PyLinter) -> None: - with tempdir(): - create_files(["identical/identical.py"]) - with open("identical/identical.py", "w", encoding="utf-8") as f: - f.write("import imp") - initialized_linter.check(["identical"]) - assert initialized_linter.stats.by_msg["deprecated-module"] == 1 +def test_lint_namespace_package_under_dir_on_path(initialized_linter: PyLinter) -> None: + """If the directory above a namespace package is on sys.path, + the namespace module under it is linted.""" + linter = initialized_linter + with tempdir() as tmpdir: + create_files(["namespace_on_path/submodule1.py"]) + os.chdir(tmpdir) + with fix_import_path([tmpdir]): + linter.check(["namespace_on_path"]) + assert linter.file_state.base_name == "namespace_on_path" |