summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-07 12:34:14 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-07 12:34:14 -0400
commit106accd07c8c54304fe67e98b88e50ddb26d3f95 (patch)
tree49608c6163e0db7c564b8d6727c1d7f225c2fc9b /tests
parent1457a85380d52d91639a2fd833227c91f734edce (diff)
downloadcmd2-git-f-strings.tar.gz
Increased unit test coverage for pexcept()f-strings
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_cmd2.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index aeddfc78..7595327f 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -2131,6 +2131,34 @@ def test_pwarning_no_style(base_app, capsys):
assert err == msg + end
+def test_pexcept_style(base_app, capsys):
+ msg = Exception('testing...')
+ ansi.allow_style = ansi.STYLE_ALWAYS
+
+ base_app.pexcept(msg)
+ out, err = capsys.readouterr()
+ assert err.startswith(ansi.style_error("EXCEPTION of type 'Exception' occurred with message: testing..."))
+
+
+def test_pexcept_no_style(base_app, capsys):
+ msg = Exception('testing...')
+ ansi.allow_style = ansi.STYLE_ALWAYS
+
+ base_app.pexcept(msg, apply_style=False)
+ out, err = capsys.readouterr()
+ assert err.startswith("EXCEPTION of type 'Exception' occurred with message: testing...")
+
+
+def test_pexcept_not_exception(base_app, capsys):
+ # Pass in a msg that is not an Exception object
+ msg = False
+ ansi.allow_style = ansi.STYLE_ALWAYS
+
+ base_app.pexcept(msg)
+ out, err = capsys.readouterr()
+ assert err.startswith(ansi.style_error(msg))
+
+
def test_ppaged(outsim_app):
msg = 'testing...'
end = '\n'