diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-06-04 13:49:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-04 13:49:52 +0200 |
commit | e49868c2bda9708c92a35474262ddfe14af0fdc9 (patch) | |
tree | add690ede408dd75bb682a64a993e1d33d387378 /tests/config | |
parent | 8ab9ab5c73f781871e320a65f73c778fe6b2a8eb (diff) | |
download | pylint-git-e49868c2bda9708c92a35474262ddfe14af0fdc9.tar.gz |
Store namespaces respective to directories (#6789)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/config')
-rw-r--r-- | tests/config/test_per_directory_config.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/config/test_per_directory_config.py b/tests/config/test_per_directory_config.py new file mode 100644 index 000000000..9bc0ef9bc --- /dev/null +++ b/tests/config/test_per_directory_config.py @@ -0,0 +1,24 @@ +# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt + + +from py._path.local import LocalPath # type: ignore[import] + +from pylint.lint import Run + + +def test_fall_back_on_base_config(tmpdir: LocalPath) -> None: + """Test that we correctly fall back on the base config.""" + # A file under the current dir should fall back to the highest level + # For pylint this is ./pylintrc + test_file = tmpdir / "test.py" + runner = Run([__name__], exit=False) + assert id(runner.linter.config) == id(runner.linter._base_config) + + # When the file is a directory that does not have any of its parents in + # linter._directory_namespaces it should default to the base config + with open(test_file, "w", encoding="utf-8") as f: + f.write("1") + Run([str(test_file)], exit=False) + assert id(runner.linter.config) == id(runner.linter._base_config) |