Skip to content

Commit 48a5556

Browse files
Use a stable file in order to have a stable exit code
1 parent 34eeaf0 commit 48a5556

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tests/config/file_to_lint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Perfect module with only documentation for configuration tests"""

tests/config/test_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
import pylint.lint
88
from pylint.lint.run import Run
99

10+
# We use an external file and not __file__ or pylint warning in this file
11+
# makes the tests fails because the exit code changes
12+
FILE_TO_LINT = str(Path(__file__).parent / "file_to_lint.py")
13+
14+
1015
def get_runner_from_config_file(
1116
config_file: Union[str, Path], expected_exit_code: int = 0
1217
) -> Run:
1318
"""Initialize pylint with the given configuration file and return the Run"""
14-
args = ["--rcfile", str(config_file), __file__]
19+
args = ["--rcfile", str(config_file), FILE_TO_LINT]
1520
# If we used `pytest.raises(SystemExit)`, the `runner` variable
1621
# would not be accessible outside the `with` block.
1722
with unittest.mock.patch("sys.exit") as mocked_exit:

0 commit comments

Comments
 (0)