diff options
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r-- | tests/test_utils.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 44421b93..f43aed4e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -8,7 +8,7 @@ import sys import pytest -from colorama import Fore +from colorama import Fore, Back import cmd2.utils as cu HELLO_WORLD = 'Hello, world!' @@ -25,6 +25,25 @@ def test_ansi_safe_wcswidth(): ansi_str = Fore.GREEN + base_str + Fore.RESET assert cu.ansi_safe_wcswidth(ansi_str) != len(ansi_str) +def test_style_message(): + base_str = HELLO_WORLD + ansi_str = Fore.BLUE + Back.GREEN + base_str + Fore.RESET + Back.RESET + '\n\n' + assert cu.style_message(base_str, end='\n\n', fg='blue', bg='green') + +def test_style_message_color_not_exist(): + base_str = HELLO_WORLD + try: + cu.style_message(base_str, fg='hello', bg='green') + assert False + except ValueError: + assert True + + try: + cu.style_message(base_str, fg='blue', bg='hello') + assert False + except ValueError: + assert True + def test_strip_quotes_no_quotes(): base_str = HELLO_WORLD stripped = cu.strip_quotes(base_str) |