summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matusiak <numerodix@gmail.com>2021-05-05 11:20:37 +1000
committerMartin Matusiak <numerodix@gmail.com>2021-05-05 11:20:37 +1000
commit1848b3eefc9fae1f4519ad0deb6681f6419c282b (patch)
treeb536004182369f866b497f806daff606e022c4f2
parentbb0e437db56823129de82e7d521f40959b0a5d86 (diff)
downloadansicolor-1848b3eefc9fae1f4519ad0deb6681f6419c282b.tar.gz
add tests for write_out and write_err
-rw-r--r--tests/test_colors.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test_colors.py b/tests/test_colors.py
index 0d16bfa..242638c 100644
--- a/tests/test_colors.py
+++ b/tests/test_colors.py
@@ -13,6 +13,8 @@ from ansicolor import wrap_string
from ansicolor import get_code_v2
from ansicolor import colorize_v2
from ansicolor import set_term_title
+from ansicolor import write_out
+from ansicolor import write_err
import ansicolor
@@ -186,4 +188,26 @@ def test_set_term_title(capsys):
set_term_title('ansicolor demo')
captured = capsys.readouterr()
- assert '\033]2;ansicolor demo\007' == captured.out \ No newline at end of file
+ assert '\033]2;ansicolor demo\007' == captured.out
+
+
+def test_write_out(capfd):
+ text = colorize("Hi there", Colors.Red, start=3, end=6)
+
+ # escapes will be stripped since we rely on capfd and os.isatty detects a
+ # tty device on the other end
+ write_out(text)
+
+ captured = capfd.readouterr()
+ assert 'Hi there' == captured.out
+
+
+def test_write_err(capfd):
+ text = colorize("Hi there", Colors.Red, start=3, end=6)
+
+ # escapes will be stripped since we rely on capfd and os.isatty detects a
+ # tty device on the other end
+ write_err(text)
+
+ captured = capfd.readouterr()
+ assert 'Hi there' == captured.err