summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Ahn <sangbumahn@gmail.com>2019-06-25 09:45:29 -0700
committerDaniel Ahn <sangbumahn@gmail.com>2019-06-25 09:45:39 -0700
commitb840f1dd2c0e55fa7cf1982194a57e598de9f7ca (patch)
tree9fe8e394789cdba30ee9c1d140b56cbc78a26109 /tests
parentd409cc5228e4f8591c31e6359de72ebe1a361b48 (diff)
downloadcmd2-git-b840f1dd2c0e55fa7cf1982194a57e598de9f7ca.tar.gz
Add 2 tests to test_utils.py for style_message()
Diffstat (limited to 'tests')
-rw-r--r--tests/test_utils.py21
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)