diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 13:33:25 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 13:33:25 -0400 |
commit | 3bf3bf65bfaa938e579984d8079045692d7f290c (patch) | |
tree | f88c4ad6a8d4f6f282cf5d5114271c598b63d027 /tests | |
parent | 1ca3ce9361ef0eb9c98ce8ec4cbd76e7b30140b2 (diff) | |
download | cmd2-git-3bf3bf65bfaa938e579984d8079045692d7f290c.tar.gz |
Always set the canonical version allow_ansi' string value
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd2.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index ab24384b..d3e51130 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -181,18 +181,25 @@ 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), - ('neVeR', False), - ('TeRMInal', False), - ('AlWaYs', False), - ('invalid', True), +@pytest.mark.parametrize('new_val, is_valid, expected', [ + (ansi.ANSI_NEVER, False, ansi.ANSI_NEVER), + ('neVeR', False, ansi.ANSI_NEVER), + (ansi.ANSI_TERMINAL, False, ansi.ANSI_TERMINAL), + ('TeRMInal', False, ansi.ANSI_TERMINAL), + (ansi.ANSI_ALWAYS, False, ansi.ANSI_ALWAYS), + ('AlWaYs', False, ansi.ANSI_ALWAYS), + ('invalid', True, ansi.ANSI_TERMINAL), ]) -def test_set_allow_ansi(base_app, new_val, is_valid): +def test_set_allow_ansi(base_app, new_val, is_valid, expected): + # Initialize allow_ansi for this test + ansi.allow_ansi = ansi.ANSI_TERMINAL + + # Use the set command to alter it out, err = run_cmd(base_app, 'set allow_ansi {}'.format(new_val)) + + # Verify the results assert bool(err) == is_valid + assert ansi.allow_ansi == expected # Reload ansi module to reset allow_ansi to its default since it's an # application-wide setting that can affect other unit tests. |