diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-02-04 22:18:56 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-02-04 22:18:56 -0500 |
commit | 14f456b0c3b70021fa650a596f81e0cfa7bd8949 (patch) | |
tree | 827e15626c891803c9fd3d667c1838f32bef8de4 /tests | |
parent | 457123d3a1376a2ab713f0ff638313b0eacfcf3e (diff) | |
download | cmd2-git-14f456b0c3b70021fa650a596f81e0cfa7bd8949.tar.gz |
Fixed a bug in a very unusual case and added some unit tests
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_cmd2.py | 7 | ||||
-rw-r--r-- | tests/test_utils.py | 19 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 671a6685..9aaebc99 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -127,6 +127,13 @@ Parameter 'qqq' not supported (type 'set' for list of parameters). assert err == expected +def test_set_no_settables(base_app): + base_app.settables = {} + out, err = run_cmd(base_app, 'set quiet True') + expected = normalize("There are no settable parameters") + assert err == expected + + @pytest.mark.parametrize('new_val, is_valid, expected', [ (ansi.STYLE_NEVER, False, ansi.STYLE_NEVER), ('neVeR', False, ansi.STYLE_NEVER), diff --git a/tests/test_utils.py b/tests/test_utils.py index 9dd54ee2..804e58be 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -531,3 +531,22 @@ def test_align_right_wide_fill_needs_padding(): width = 6 aligned = cu.align_right(text, fill_char=fill_char, width=width) assert aligned == fill_char + ' ' + text + + +def test_str_to_bool_true(): + assert cu.str_to_bool('true') + assert cu.str_to_bool('True') + assert cu.str_to_bool('TRUE') + +def test_str_to_bool_false(): + assert not cu.str_to_bool('false') + assert not cu.str_to_bool('False') + assert not cu.str_to_bool('FALSE') + +def test_str_to_bool_invalid(): + with pytest.raises(ValueError): + cu.str_to_bool('other') + +def test_str_to_bool_bad_input(): + with pytest.raises(ValueError): + cu.str_to_bool(1) |