diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 11:57:40 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 11:57:40 -0400 |
commit | e73661cee4215a0ecf496316bbeac4663c722ed2 (patch) | |
tree | 0d485cf88761da09c079d30d5285a2fd81f42d25 /tests | |
parent | c1812a9fdb8c3a80e8ecde97f1627421e7815f70 (diff) | |
download | cmd2-git-e73661cee4215a0ecf496316bbeac4663c722ed2.tar.gz |
Added validation when setting allow_ansi
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd2.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 1936c75c..47d8ce44 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -181,6 +181,20 @@ now: True out, err = run_cmd(base_app, 'set quiet') assert out == ['quiet: True'] +@pytest.mark.parametrize('new_val, is_valid', [ + (ansi.ANSI_NEVER, False), + (ansi.ANSI_TERMINAL, False), + (ansi.ANSI_ALWAYS, False), + ('invalid', True), +]) +def test_set_allow_ansi(base_app, new_val, is_valid): + out, err = run_cmd(base_app, 'set allow_ansi {}'.format(new_val)) + assert bool(err) == is_valid + + # Reload ansi module to reset allow_ansi 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): |