From 14f456b0c3b70021fa650a596f81e0cfa7bd8949 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Tue, 4 Feb 2020 22:18:56 -0500 Subject: Fixed a bug in a very unusual case and added some unit tests --- tests/test_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_utils.py') 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) -- cgit v1.2.1