summaryrefslogtreecommitdiff
path: root/tests/test_ansi.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-09 22:45:53 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-09 22:45:53 -0500
commit591bd29cb4a3bcb9b1f40ffc1f30429c6501ebdb (patch)
tree46c1e3af762c9cb222c6ae90bf0446d6eca4b388 /tests/test_ansi.py
parent10b844809e3a9500274dc4af4e780708975ba905 (diff)
parentd4556962799e68ea4d54ff86186428d17edcaef9 (diff)
downloadcmd2-git-591bd29cb4a3bcb9b1f40ffc1f30429c6501ebdb.tar.gz
Merge branch 'master' into generating_output_docs
# Conflicts: # docs/features/generating_output.rst # docs/features/settings.rst
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():