From 5b46aca8e449f6d1902b8fbb20e30dcf4528c1b8 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 9 Nov 2021 15:56:22 +0100 Subject: Use a stable file in order to have a stable exit code --- tests/config/file_to_lint.py | 1 + tests/config/test_config.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/config/file_to_lint.py 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 921826702..4e7f5ffff 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -7,12 +7,16 @@ from typing import 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 change +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: -- cgit v1.2.1