diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2021-03-05 01:23:53 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-03-05 19:08:42 +0100 |
commit | b8c9472706de23e79d540a4df717cf2966483891 (patch) | |
tree | 839a51e9406cb06041cdd94bb4e0a2db99c6f08c | |
parent | 68309155f0da806f9d5dc97fd2d59168869245fe (diff) | |
download | pylint-git-b8c9472706de23e79d540a4df717cf2966483891.tar.gz |
Extract test case
-rw-r--r-- | tests/test_self.py | 35 |
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" |