summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-11-23 18:35:08 -0500
committerGitHub <noreply@github.com>2019-11-23 18:35:08 -0500
commitaeb517d7249b6f17cbb0d09a1a22f2d689be1d57 (patch)
tree6fa03bbfe2c031d5312861e86f7e8f828d633a09 /tests/test_cmd2.py
parent3f1b75df79fb2616d43faaa3c30552953c55488b (diff)
parentc5632b3a703a27ed975667d32fd7ff62097cbed6 (diff)
downloadcmd2-git-aeb517d7249b6f17cbb0d09a1a22f2d689be1d57.tar.gz
Merge pull request #817 from python-cmd2/pwarning
Added apply_style to pwarning()
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index f9c3e61d..88447416 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1882,6 +1882,38 @@ def test_nonexistent_macro(base_app):
assert exception is not None
+def test_perror_style(base_app, capsys):
+ msg = 'testing...'
+ end = '\n'
+ ansi.allow_ansi = ansi.ANSI_ALWAYS
+ base_app.perror(msg)
+ out, err = capsys.readouterr()
+ assert err == ansi.style_error(msg) + end
+
+def test_perror_no_style(base_app, capsys):
+ msg = 'testing...'
+ end = '\n'
+ ansi.allow_ansi = ansi.ANSI_ALWAYS
+ base_app.perror(msg, apply_style=False)
+ out, err = capsys.readouterr()
+ assert err == msg + end
+
+def test_pwarning_style(base_app, capsys):
+ msg = 'testing...'
+ end = '\n'
+ ansi.allow_ansi = ansi.ANSI_ALWAYS
+ base_app.pwarning(msg)
+ out, err = capsys.readouterr()
+ assert err == ansi.style_warning(msg) + end
+
+def test_pwarning_no_style(base_app, capsys):
+ msg = 'testing...'
+ end = '\n'
+ ansi.allow_ansi = ansi.ANSI_ALWAYS
+ base_app.pwarning(msg, apply_style=False)
+ out, err = capsys.readouterr()
+ assert err == msg + end
+
def test_ppaged(outsim_app):
msg = 'testing...'
end = '\n'
@@ -1889,6 +1921,18 @@ def test_ppaged(outsim_app):
out = outsim_app.stdout.getvalue()
assert out == msg + end
+def test_ppaged_blank(outsim_app):
+ msg = ''
+ outsim_app.ppaged(msg)
+ out = outsim_app.stdout.getvalue()
+ assert not out
+
+def test_ppaged_none(outsim_app):
+ msg = None
+ outsim_app.ppaged(msg)
+ out = outsim_app.stdout.getvalue()
+ assert not out
+
def test_ppaged_strips_ansi_when_redirecting(outsim_app):
msg = 'testing...'
end = '\n'