summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_self.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/tests/test_self.py b/tests/test_self.py
index 14177c3ea..5b55f6cca 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -718,52 +718,59 @@ class TestRunTC:
cwd=str(tmpdir),
)
- # Appending a colon to PYTHONPATH should not break path stripping
- # https://github.com/PyCQA/pylint/issues/3636
+ # Linting this astroid file does not import it
with tmpdir.as_cwd():
- orig_pythonpath = os.environ.get("PYTHONPATH")
- os.environ["PYTHONPATH"] = os.environ.get("PYTHONPATH", "") + ":"
subprocess.check_output(
[
sys.executable,
"-m",
"pylint",
+ "-j2",
"astroid.py",
"--disable=import-error,unused-import",
],
cwd=str(tmpdir),
)
- if orig_pythonpath is not None:
- os.environ["PYTHONPATH"] = orig_pythonpath
- # Linting this astroid file does not import it
+ # Test with multiple jobs for hmac.py for which we have a
+ # CVE against: https://github.com/PyCQA/pylint/issues/959
with tmpdir.as_cwd():
- subprocess.check_output(
+ subprocess.call(
[
sys.executable,
"-m",
"pylint",
"-j2",
- "astroid.py",
+ "hmac.py",
"--disable=import-error,unused-import",
],
cwd=str(tmpdir),
)
- # Test with multiple jobs for hmac.py for which we have a
- # CVE against: https://github.com/PyCQA/pylint/issues/959
+ @staticmethod
+ def test_do_not_import_files_from_local_directory_with_pythonpath(tmpdir):
+ p_astroid = tmpdir / "astroid.py"
+ p_astroid.write("'Docstring'\nimport completely_unknown\n")
+ p_hmac = tmpdir / "hmac.py"
+ p_hmac.write("'Docstring'\nimport completely_unknown\n")
+
+ # Appending a colon to PYTHONPATH should not break path stripping
+ # https://github.com/PyCQA/pylint/issues/3636
with tmpdir.as_cwd():
- subprocess.call(
+ orig_pythonpath = os.environ.get("PYTHONPATH")
+ os.environ["PYTHONPATH"] = os.environ.get("PYTHONPATH", "") + ":"
+ subprocess.check_output(
[
sys.executable,
"-m",
"pylint",
- "-j2",
- "hmac.py",
+ "astroid.py",
"--disable=import-error,unused-import",
],
cwd=str(tmpdir),
)
+ if orig_pythonpath is not None:
+ os.environ["PYTHONPATH"] = orig_pythonpath
def test_allow_import_of_files_found_in_modules_during_parallel_check(self, tmpdir):
test_directory = tmpdir / "test_directory"