diff options
author | xNinjaKittyx <xNinjaKittyx@users.noreply.github.com> | 2020-12-15 17:21:33 -0800 |
---|---|---|
committer | xNinjaKittyx <xNinjaKittyx@users.noreply.github.com> | 2020-12-15 18:20:13 -0800 |
commit | 9aa54a5b27468d61337528cb1e1b5b9b11a80978 (patch) | |
tree | 567693115cc101efb9254a96d96d80e9f9ccd557 /tests/test_argparse_custom.py | |
parent | 03c65c60b39e369958b056c5c844d36d515c8a63 (diff) | |
download | cmd2-git-ci_improvements.tar.gz |
Adds pre-commit config to run various lintersci_improvements
This ads black, isort, pyupgrade, and flake8 to pre-commit-config.yaml
There are also some small changes to travis.yml and tasks.py to reduce
some repeated configurations that should be consolidated into
setup.cfg. Most other changes are automated by the linter scripts.
Diffstat (limited to 'tests/test_argparse_custom.py')
-rw-r--r-- | tests/test_argparse_custom.py | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index e2b3bb97..24a037fa 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -15,6 +15,7 @@ from .conftest import run_cmd class ApCustomTestApp(cmd2.Cmd): """Test app for cmd2's argparse customization""" + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -40,15 +41,18 @@ def fake_func(): pass -@pytest.mark.parametrize('kwargs, is_valid', [ - ({'choices_function': fake_func}, True), - ({'choices_method': fake_func}, True), - ({'completer_function': fake_func}, True), - ({'completer_method': fake_func}, True), - ({'choices_function': fake_func, 'choices_method': fake_func}, False), - ({'choices_method': fake_func, 'completer_function': fake_func}, False), - ({'completer_function': fake_func, 'completer_method': fake_func}, False), -]) +@pytest.mark.parametrize( + 'kwargs, is_valid', + [ + ({'choices_function': fake_func}, True), + ({'choices_method': fake_func}, True), + ({'completer_function': fake_func}, True), + ({'completer_method': fake_func}, True), + ({'choices_function': fake_func, 'choices_method': fake_func}, False), + ({'choices_method': fake_func, 'completer_function': fake_func}, False), + ({'completer_function': fake_func, 'completer_method': fake_func}, False), + ], +) def test_apcustom_choices_callable_count(kwargs, is_valid): parser = Cmd2ArgumentParser() try: @@ -59,12 +63,15 @@ def test_apcustom_choices_callable_count(kwargs, is_valid): assert 'Only one of the following parameters' in str(ex) -@pytest.mark.parametrize('kwargs', [ - ({'choices_function': fake_func}), - ({'choices_method': fake_func}), - ({'completer_function': fake_func}), - ({'completer_method': fake_func}) -]) +@pytest.mark.parametrize( + 'kwargs', + [ + ({'choices_function': fake_func}), + ({'choices_method': fake_func}), + ({'completer_function': fake_func}), + ({'completer_method': fake_func}), + ], +) def test_apcustom_no_choices_callables_alongside_choices(kwargs): with pytest.raises(TypeError) as excinfo: parser = Cmd2ArgumentParser() @@ -72,12 +79,15 @@ def test_apcustom_no_choices_callables_alongside_choices(kwargs): assert 'None of the following parameters can be used alongside a choices parameter' in str(excinfo.value) -@pytest.mark.parametrize('kwargs', [ - ({'choices_function': fake_func}), - ({'choices_method': fake_func}), - ({'completer_function': fake_func}), - ({'completer_method': fake_func}) -]) +@pytest.mark.parametrize( + 'kwargs', + [ + ({'choices_function': fake_func}), + ({'choices_method': fake_func}), + ({'completer_function': fake_func}), + ({'completer_method': fake_func}), + ], +) def test_apcustom_no_choices_callables_when_nargs_is_0(kwargs): with pytest.raises(TypeError) as excinfo: parser = Cmd2ArgumentParser() @@ -119,12 +129,7 @@ def test_apcustom_nargs_range_validation(cust_app): assert not err -@pytest.mark.parametrize('nargs_tuple', [ - (), - ('f', 5), - (5, 'f'), - (1, 2, 3), -]) +@pytest.mark.parametrize('nargs_tuple', [(), ('f', 5), (5, 'f'), (1, 2, 3),]) def test_apcustom_narg_invalid_tuples(nargs_tuple): with pytest.raises(ValueError) as excinfo: parser = Cmd2ArgumentParser() @@ -200,6 +205,7 @@ def test_apcustom_narg_tuple_other_ranges(): def test_apcustom_print_message(capsys): import sys + test_message = 'The test message' # Specify the file @@ -247,6 +253,7 @@ def test_apcustom_required_options(): def test_override_parser(): import importlib + from cmd2 import DEFAULT_ARGUMENT_PARSER # The standard parser is Cmd2ArgumentParser @@ -259,6 +266,7 @@ def test_override_parser(): # Verify DEFAULT_ARGUMENT_PARSER is now our CustomParser from examples.custom_parser import CustomParser + assert DEFAULT_ARGUMENT_PARSER == CustomParser |