diff options
author | Matus Valo <matusvalo@users.noreply.github.com> | 2022-05-13 08:06:04 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2022-05-13 17:30:49 +0200 |
commit | 9c2fe99946af40478e366dc852545ddb90559822 (patch) | |
tree | b64957ab9535e0d72ab3529705461ac2c3d3ec3c /tests/test_self.py | |
parent | 33f3fcf047227ddd7d5816184ac4bf01f60863bb (diff) | |
download | pylint-git-9c2fe99946af40478e366dc852545ddb90559822.tar.gz |
Respect ignore configuration options when --recursive=y. (#6528)
* Ignore specified files/directories in recursive mode
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'tests/test_self.py')
-rw-r--r-- | tests/test_self.py | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/tests/test_self.py b/tests/test_self.py index 36084b717..27b1e7bed 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -1276,17 +1276,91 @@ class TestRunTC: assert not ex.value.code % 2 def test_regression_recursive(self): + """Tests if error is raised when linter is executed over directory not using --recursive=y""" self._test_output( [join(HERE, "regrtest_data", "directory", "subdirectory"), "--recursive=n"], expected_output="No such file or directory", ) def test_recursive(self): + """Tests if running linter over directory using --recursive=y""" self._runtest( [join(HERE, "regrtest_data", "directory", "subdirectory"), "--recursive=y"], code=0, ) + def test_ignore_recursive(self): + """Tests recursive run of linter ignoring directory using --ignore parameter. + + Ignored directory contains files yielding lint errors. If directory is not ignored + test would fail due these errors. + """ + self._runtest( + [ + join(HERE, "regrtest_data", "directory"), + "--recursive=y", + "--ignore=ignored_subdirectory", + ], + code=0, + ) + + self._runtest( + [ + join(HERE, "regrtest_data", "directory"), + "--recursive=y", + "--ignore=failing.py", + ], + code=0, + ) + + def test_ignore_pattern_recursive(self): + """Tests recursive run of linter ignoring directory using --ignore-parameter parameter. + + Ignored directory contains files yielding lint errors. If directory is not ignored + test would fail due these errors. + """ + self._runtest( + [ + join(HERE, "regrtest_data", "directory"), + "--recursive=y", + "--ignore-pattern=ignored_.*", + ], + code=0, + ) + + self._runtest( + [ + join(HERE, "regrtest_data", "directory"), + "--recursive=y", + "--ignore-pattern=failing.*", + ], + code=0, + ) + + def test_ignore_path_recursive(self): + """Tests recursive run of linter ignoring directory using --ignore-path parameter. + + Ignored directory contains files yielding lint errors. If directory is not ignored + test would fail due these errors. + """ + self._runtest( + [ + join(HERE, "regrtest_data", "directory"), + "--recursive=y", + "--ignore-path=.*ignored.*", + ], + code=0, + ) + + self._runtest( + [ + join(HERE, "regrtest_data", "directory"), + "--recursive=y", + "--ignore-path=.*failing.*", + ], + code=0, + ) + def test_recursive_current_dir(self): with _test_sys_path(): # pytest is including directory HERE/regrtest_data to sys.path which causes @@ -1297,7 +1371,7 @@ class TestRunTC: if not os.path.basename(path) == "regrtest_data" ] with _test_cwd(): - os.chdir(join(HERE, "regrtest_data", "directory")) + os.chdir(join(HERE, "regrtest_data", "directory", "subdirectory")) self._runtest( [".", "--recursive=y"], code=0, |