diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-07 12:34:14 -0400 |
|---|---|---|
| committer | anselor <anselor@gmail.com> | 2021-04-13 11:08:43 -0400 |
| commit | 33a451db7b911a5a5ee5a3473a2e07eeeb308e55 (patch) | |
| tree | 49608c6163e0db7c564b8d6727c1d7f225c2fc9b /tests | |
| parent | 83a5ec0a0bdfc81efcc162478909862420d234a1 (diff) | |
| download | cmd2-git-33a451db7b911a5a5ee5a3473a2e07eeeb308e55.tar.gz | |
Increased unit test coverage for pexcept()
Diffstat (limited to 'tests')
| -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' |
