summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-09 15:56:22 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-10 00:01:52 +0100
commit48a5556a7c570e91e227746245209bda3fd46daa (patch)
tree91cb051c94a5e9b4a700b597de47d0eef5b88227
parent34eeaf01330414cafad3fbcc8298953f265645be (diff)
downloadpylint-git-48a5556a7c570e91e227746245209bda3fd46daa.tar.gz
Use a stable file in order to have a stable exit code
-rw-r--r--tests/config/file_to_lint.py1
-rw-r--r--tests/config/test_config.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/tests/config/file_to_lint.py b/tests/config/file_to_lint.py
new file mode 100644
index 000000000..e7c395dd9
--- /dev/null
+++ b/tests/config/file_to_lint.py
@@ -0,0 +1 @@
+"""Perfect module with only documentation for configuration tests"""
diff --git a/tests/config/test_config.py b/tests/config/test_config.py
index 37bd519b6..8ce5d9b42 100644
--- a/tests/config/test_config.py
+++ b/tests/config/test_config.py
@@ -7,11 +7,16 @@ from typing import Optional, Set, Union
import pylint.lint
from pylint.lint.run import Run
+# We use an external file and not __file__ or pylint warning in this file
+# makes the tests fails because the exit code changes
+FILE_TO_LINT = str(Path(__file__).parent / "file_to_lint.py")
+
+
def get_runner_from_config_file(
config_file: Union[str, Path], expected_exit_code: int = 0
) -> Run:
"""Initialize pylint with the given configuration file and return the Run"""
- args = ["--rcfile", str(config_file), __file__]
+ args = ["--rcfile", str(config_file), FILE_TO_LINT]
# If we used `pytest.raises(SystemExit)`, the `runner` variable
# would not be accessible outside the `with` block.
with unittest.mock.patch("sys.exit") as mocked_exit: