summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-02-04 22:18:56 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2020-02-04 22:18:56 -0500
commit14f456b0c3b70021fa650a596f81e0cfa7bd8949 (patch)
tree827e15626c891803c9fd3d667c1838f32bef8de4 /tests/test_utils.py
parent457123d3a1376a2ab713f0ff638313b0eacfcf3e (diff)
downloadcmd2-git-14f456b0c3b70021fa650a596f81e0cfa7bd8949.tar.gz
Fixed a bug in a very unusual case and added some unit tests
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py19
1 files changed, 19 insertions, 0 deletions
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)