diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-21 17:13:00 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-21 17:13:00 -0400 |
commit | 24c3d8d7bc9ebab4a89017389a2f79e66de4db18 (patch) | |
tree | ee9e47ba7e5e254ca5bf3480d7b331bf891fac2d /tests/test_utils.py | |
parent | 92dd10ec702e0cde0ee1fd157957aa816f2c137f (diff) | |
parent | dbe485957b421f6fd973b3a493de7b264b363d54 (diff) | |
download | cmd2-git-24c3d8d7bc9ebab4a89017389a2f79e66de4db18.tar.gz |
Merge branch 'master' into alert_printer
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r-- | tests/test_utils.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 691abdf8..8c8daa39 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -76,3 +76,38 @@ def test_natural_sort(): assert cu.natural_sort(my_list) == ['A', 'café', 'micro', 'unity', 'X0', 'x1', 'X2', 'X11', 'x22', 'µ'] my_list = ['a3', 'a22', 'A2', 'A11', 'a1'] assert cu.natural_sort(my_list) == ['a1', 'A2', 'a3', 'A11', 'a22'] + +def test_is_quoted_short(): + my_str = '' + assert not cu.is_quoted(my_str) + your_str = '"' + assert not cu.is_quoted(your_str) + +def test_is_quoted_yes(): + my_str = '"This is a test"' + assert cu.is_quoted(my_str) + your_str = "'of the emergengy broadcast system'" + assert cu.is_quoted(your_str) + +def test_is_quoted_no(): + my_str = '"This is a test' + assert not cu.is_quoted(my_str) + your_str = "of the emergengy broadcast system'" + assert not cu.is_quoted(your_str) + simple_str = "hello world" + assert not cu.is_quoted(simple_str) + +def test_quote_string_if_needed_yes(): + my_str = "Hello World" + assert cu.quote_string_if_needed(my_str) == '"' + my_str + '"' + your_str = '"foo" bar' + assert cu.quote_string_if_needed(your_str) == "'" + your_str + "'" + +def test_quot_string_if_needed_no(): + my_str = "HelloWorld" + assert cu.quote_string_if_needed(my_str) == my_str + your_str = "'Hello World'" + assert cu.quote_string_if_needed(your_str) == your_str + + + |