summaryrefslogtreecommitdiff
path: root/tests/test_ansi.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_ansi.py')
-rw-r--r--tests/test_ansi.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/test_ansi.py b/tests/test_ansi.py
index 056bb2db..cb68cb28 100644
--- a/tests/test_ansi.py
+++ b/tests/test_ansi.py
@@ -10,17 +10,17 @@ import cmd2.ansi as ansi
HELLO_WORLD = 'Hello, world!'
-def test_strip_ansi():
+def test_strip_style():
base_str = HELLO_WORLD
ansi_str = ansi.style(base_str, fg='green')
assert base_str != ansi_str
- assert base_str == ansi.strip_ansi(ansi_str)
+ assert base_str == ansi.strip_style(ansi_str)
-def test_ansi_safe_wcswidth():
+def test_style_aware_wcswidth():
base_str = HELLO_WORLD
ansi_str = ansi.style(base_str, fg='green')
- assert ansi.ansi_safe_wcswidth(ansi_str) != len(ansi_str)
+ assert ansi.style_aware_wcswidth(ansi_str) != len(ansi_str)
def test_style_none():
@@ -45,10 +45,16 @@ def test_style_bg():
def test_style_bold():
base_str = HELLO_WORLD
- ansi_str = ansi.BRIGHT + base_str + ansi.NORMAL
+ ansi_str = ansi.INTENSITY_BRIGHT + base_str + ansi.INTENSITY_NORMAL
assert ansi.style(base_str, bold=True) == ansi_str
+def test_style_dim():
+ base_str = HELLO_WORLD
+ ansi_str = ansi.INTENSITY_DIM + base_str + ansi.INTENSITY_NORMAL
+ assert ansi.style(base_str, dim=True) == ansi_str
+
+
def test_style_underline():
base_str = HELLO_WORLD
ansi_str = ansi.UNDERLINE_ENABLE + base_str + ansi.UNDERLINE_DISABLE
@@ -59,9 +65,12 @@ def test_style_multi():
base_str = HELLO_WORLD
fg_color = 'blue'
bg_color = 'green'
- ansi_str = ansi.FG_COLORS[fg_color] + ansi.BG_COLORS[bg_color] + ansi.BRIGHT + ansi.UNDERLINE_ENABLE + \
- base_str + ansi.FG_RESET + ansi.BG_RESET + ansi.NORMAL + ansi.UNDERLINE_DISABLE
- assert ansi.style(base_str, fg=fg_color, bg=bg_color, bold=True, underline=True) == ansi_str
+ ansi_str = (ansi.FG_COLORS[fg_color] + ansi.BG_COLORS[bg_color] +
+ ansi.INTENSITY_BRIGHT + ansi.INTENSITY_DIM + ansi.UNDERLINE_ENABLE +
+ base_str +
+ ansi.FG_RESET + ansi.BG_RESET +
+ ansi.INTENSITY_NORMAL + ansi.INTENSITY_NORMAL + ansi.UNDERLINE_DISABLE)
+ assert ansi.style(base_str, fg=fg_color, bg=bg_color, bold=True, dim=True, underline=True) == ansi_str
def test_style_color_not_exist():