Skip to content

Commit eeb8f38

Browse files
committed
pylint: add failing test when ambiguous abbreviated parameters are set in a config file
This is confusing behaviour. The output is: ``` usage: pylint [options] pylint: error: ambiguous option: --no could match --notes, --notes-rgx, --no-docstring-rgx ``` The exit code is 2 which doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes
1 parent 999d38b commit eeb8f38

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/lint/test_run_pylint.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
33
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
44

5+
from pathlib import Path
56

67
import pytest
78
from _pytest.capture import CaptureFixture
@@ -16,3 +17,20 @@ def test_run_pylint_with_invalid_argument(capsys: CaptureFixture[str]) -> None:
1617
captured = capsys.readouterr()
1718
assert captured.err.startswith("usage: pylint [options]")
1819
assert ex.value.code == 32
20+
21+
22+
def test_run_pylint_with_invalid_argument_in_config(
23+
capsys: CaptureFixture[str], tmp_path: Path
24+
) -> None:
25+
"""Check that appropriate exit code is used with an ambiguous
26+
argument in a config file.
27+
"""
28+
test_file = tmp_path / "testpylintrc"
29+
with open(test_file, "w", encoding="utf-8") as f:
30+
f.write("[MASTER]\nno=")
31+
32+
with pytest.raises(SystemExit) as ex:
33+
run_pylint(["--rcfile", f"{test_file}"])
34+
captured = capsys.readouterr()
35+
assert captured.err.startswith("usage: pylint [options]")
36+
assert ex.value.code == 32

0 commit comments

Comments
 (0)