diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-07 12:34:14 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-07 12:34:14 -0400 |
commit | 106accd07c8c54304fe67e98b88e50ddb26d3f95 (patch) | |
tree | 49608c6163e0db7c564b8d6727c1d7f225c2fc9b | |
parent | 1457a85380d52d91639a2fd833227c91f734edce (diff) | |
download | cmd2-git-f-strings.tar.gz |
Increased unit test coverage for pexcept()f-strings
-rwxr-xr-x | tests/test_cmd2.py | 28 |
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' |