summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 0b4c60d6..376658e5 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -79,7 +79,7 @@ def test_base_argparse_help(base_app):
def test_base_invalid_option(base_app):
out, err = run_cmd(base_app, 'set -z')
- assert err[0] == 'Usage: set [-h] [-l] [param] [value]'
+ assert err[0] == 'Usage: set [-h] [-v] [param] [value]'
assert 'Error: unrecognized arguments: -z' in err[1]
def test_base_shortcuts(base_app):
@@ -103,7 +103,7 @@ def test_base_show(base_app):
def test_base_show_long(base_app):
# force editor to be 'vim' so test is repeatable across platforms
base_app.editor = 'vim'
- out, err = run_cmd(base_app, 'set -l')
+ out, err = run_cmd(base_app, 'set -v')
expected = normalize(SHOW_LONG)
assert out == expected
@@ -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)