summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-02-06 22:50:00 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2020-02-06 22:50:00 -0500
commite66dc6f7078e1d4928ef58ccf48f4718b61d8c35 (patch)
treeefbdf93ee7c44acce04cd6758eee4c155838001f /tests
parentede9f3e77a59281a442227ed9b4b92e62e85d2b9 (diff)
downloadcmd2-git-e66dc6f7078e1d4928ef58ccf48f4718b61d8c35.tar.gz
Having two parallel datastructures each for foreground and background colors felt really clunky - now we just have one
The Enum classes are now smart and deal with it all.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ansi.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/test_ansi.py b/tests/test_ansi.py
index f711fc1a..51c3b50f 100644
--- a/tests/test_ansi.py
+++ b/tests/test_ansi.py
@@ -32,14 +32,14 @@ def test_style_none():
def test_style_fg():
base_str = HELLO_WORLD
fg_color = 'blue'
- ansi_str = ansi.FG_COLORS[fg_color] + base_str + ansi.FG_RESET
+ ansi_str = ansi.fg.get_value(fg_color) + base_str + ansi.FG_RESET
assert ansi.style(base_str, fg=fg_color) == ansi_str
def test_style_bg():
base_str = HELLO_WORLD
bg_color = 'green'
- ansi_str = ansi.BG_COLORS[bg_color] + base_str + ansi.BG_RESET
+ ansi_str = ansi.bg.get_value(bg_color) + base_str + ansi.BG_RESET
assert ansi.style(base_str, bg=bg_color) == ansi_str
@@ -65,7 +65,7 @@ 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_str = (ansi.fg.get_value(fg_color) + ansi.bg.get_value(bg_color) +
ansi.INTENSITY_BRIGHT + ansi.INTENSITY_DIM + ansi.UNDERLINE_ENABLE +
base_str +
ansi.FG_RESET + ansi.BG_RESET +
@@ -85,7 +85,7 @@ def test_style_color_not_exist():
def test_fg_lookup_exist():
fg_color = 'green'
- assert ansi.fg_lookup(fg_color) == ansi.FG_COLORS[fg_color]
+ assert ansi.fg_lookup(fg_color) == ansi.fg.get_value(fg_color)
def test_fg_lookup_nonexist():
@@ -95,7 +95,7 @@ def test_fg_lookup_nonexist():
def test_bg_lookup_exist():
bg_color = 'green'
- assert ansi.bg_lookup(bg_color) == ansi.BG_COLORS[bg_color]
+ assert ansi.bg_lookup(bg_color) == ansi.bg.get_value(bg_color)
def test_bg_lookup_nonexist():
@@ -133,3 +133,8 @@ def test_bg_enum():
def test_bg_enum_to_str():
assert str(ansi.bg.blue) == ansi.bg_lookup('blue')
+def test_fg_colors():
+ assert list(ansi.fg.__members__.keys()) == ansi.fg.colors()
+
+def test_bg_colors():
+ assert list(ansi.bg.__members__.keys()) == ansi.bg.colors()