diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-05-17 13:54:17 +0200 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-05-21 15:23:24 +0200 |
commit | c303a450f127df93bd9ee5a41a7d14408b741b7a (patch) | |
tree | 7fe6c5774cf90d734c9664bf7b15db6da1179100 /tests/config | |
parent | 9d782026d43e48e49f3ddb95bfb511df1f456e16 (diff) | |
download | pylint-git-c303a450f127df93bd9ee5a41a7d14408b741b7a.tar.gz |
Add setup and --help command to pylint-config
Diffstat (limited to 'tests/config')
-rw-r--r-- | tests/config/pylint_config/test_pylint_config_help.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/config/pylint_config/test_pylint_config_help.py b/tests/config/pylint_config/test_pylint_config_help.py new file mode 100644 index 000000000..fcd57894a --- /dev/null +++ b/tests/config/pylint_config/test_pylint_config_help.py @@ -0,0 +1,44 @@ +# 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 + +"""Test for the 'pylint-config generate' command.""" + + +import warnings + +import pytest +from pytest import CaptureFixture + +from pylint.lint.run import _PylintConfigRun as Run + + +def test_pylint_config_main_messages(capsys: CaptureFixture[str]) -> None: + """Check that the help messages are displayed correctly.""" + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message="NOTE:.*", category=UserWarning) + Run([], exit=False) + captured = capsys.readouterr() + assert captured.out.startswith("usage: pylint-config [options]") + assert "--interactive" not in captured.out + + Run(["-h"], exit=False) + captured_two = capsys.readouterr() + assert captured_two.out == captured.out + + with pytest.raises(SystemExit): + Run(["generate", "-h"]) + captured = capsys.readouterr() + assert captured.out.startswith("usage: pylint-config [options] generate") + assert "--interactive" in captured.out + + with pytest.raises(SystemExit) as ex: + Run(["generate"]) + captured_two = capsys.readouterr() + assert captured_two.out == captured.out + # This gets auto-raised by argparse to be 0. + assert ex.value.code == 32 + + with pytest.raises(SystemExit) as ex: + Run(["-h"]) + assert ex.value.code == 32 |