summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matusiak <numerodix@gmail.com>2021-05-05 18:23:42 +1000
committerMartin Matusiak <numerodix@gmail.com>2021-05-05 18:23:42 +1000
commitdc6ba48e9e102f5b8c5b7c2804435f6d1a1f5138 (patch)
tree9295d840175d5269394af7ea015716c6360c324d
parent833fd3f38aeee6af4069278b90af5b22381b044d (diff)
downloadansicolor-dc6ba48e9e102f5b8c5b7c2804435f6d1a1f5138.tar.gz
Revert "try removing disabled tests"
This reverts commit 917bc82a6d83c44719854742c8040257d90a5dc5.
-rw-r--r--tests/test_colors.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_colors.py b/tests/test_colors.py
index 43ae309..37c53e3 100644
--- a/tests/test_colors.py
+++ b/tests/test_colors.py
@@ -19,6 +19,16 @@ from ansicolor import write_out
import ansicolor
+@contextlib.contextmanager
+def disabled_state():
+ ansicolor.ansicolor._disabled = True
+
+ try:
+ # run the test with colors disabled
+ yield
+
+ finally:
+ ansicolor.ansicolor._disabled = False
def test_codes():
@@ -45,6 +55,9 @@ def test_codes():
assert "\033[1;7;31m" == get_code(Colors.Red, bold=True, reverse=True)
+def test_codes_disabled():
+ with disabled_state():
+ assert "" == get_code(Colors.Black)
def test_codes_v2():
@@ -91,6 +104,9 @@ def test_codes_v2():
)
+def test_codes_v2_disabled():
+ with disabled_state():
+ assert "" == get_code_v2(Colors.Black)
def test_coloring():
@@ -231,6 +247,10 @@ def test_wrap_string():
)
+def test_wrap_string_disabled():
+ with disabled_state():
+ assert "Hi|there" == wrap_string("Hi there", 3, Colors.Red)
+ assert "|i there" == wrap_string("Hi there", 0, Colors.Red)
def test_strip_escapes():