diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-10 11:01:17 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-10 11:01:17 -0500 |
commit | 4eca7714b5a70af81acc4467275419fa1d5e29f0 (patch) | |
tree | 523934b99a532f2f4d5195cc15444738413973ab /tests | |
parent | c3f81604713796af27352a393eba114f9b581e0f (diff) | |
download | cmd2-git-4eca7714b5a70af81acc4467275419fa1d5e29f0.tar.gz |
Corrected issue where the actual new value was not always being printed in do_set.
Fixed do_set unit test.
Made allow_ansi setter error message consistent with str_to_bool.
Updated a docstring
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_cmd2.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 0b4c60d6..e0b2ba9d 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -145,13 +145,13 @@ def test_set_no_settables(base_app): @pytest.mark.parametrize('new_val, is_valid, expected', [ - (ansi.STYLE_NEVER, False, ansi.STYLE_NEVER), - ('neVeR', False, ansi.STYLE_NEVER), - (ansi.STYLE_TERMINAL, False, ansi.STYLE_TERMINAL), - ('TeRMInal', False, ansi.STYLE_TERMINAL), - (ansi.STYLE_ALWAYS, False, ansi.STYLE_ALWAYS), - ('AlWaYs', False, ansi.STYLE_ALWAYS), - ('invalid', True, ansi.STYLE_TERMINAL), + (ansi.STYLE_NEVER, True, ansi.STYLE_NEVER), + ('neVeR', True, ansi.STYLE_NEVER), + (ansi.STYLE_TERMINAL, True, ansi.STYLE_TERMINAL), + ('TeRMInal', True, ansi.STYLE_TERMINAL), + (ansi.STYLE_ALWAYS, True, ansi.STYLE_ALWAYS), + ('AlWaYs', True, ansi.STYLE_ALWAYS), + ('invalid', False, ansi.STYLE_TERMINAL), ]) def test_set_allow_style(base_app, new_val, is_valid, expected): # Initialize allow_style for this test @@ -161,14 +161,17 @@ def test_set_allow_style(base_app, new_val, is_valid, expected): out, err = run_cmd(base_app, 'set allow_style {}'.format(new_val)) # Verify the results - assert bool(err) == is_valid assert ansi.allow_style == expected + if is_valid: + assert not err + assert "now: {!r}".format(new_val.capitalize()) in out[1] # Reload ansi module to reset allow_style to its default since it's an # application-wide setting that can affect other unit tests. import importlib importlib.reload(ansi) + class OnChangeHookApp(cmd2.Cmd): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) |