diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-05-28 10:54:10 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-05-28 10:54:10 -0400 |
commit | 6f91bea16a00f48ff6be729ed12a5920ebac3baa (patch) | |
tree | 1fef77d75b0ee0dbde5158f01230ce07f48bbeb8 /tests/test_cmd2.py | |
parent | 6460d5707fffc725c50e0642b1e1e2edafa18d87 (diff) | |
download | cmd2-git-6f91bea16a00f48ff6be729ed12a5920ebac3baa.tar.gz |
Removed pwarning() calls when command raises SystemExit
Added unit tests
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-x | tests/test_cmd2.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 33f75c9e..bc0e0a94 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -466,6 +466,17 @@ def test_in_script(request): assert "WE ARE IN SCRIPT" in out[-1] +def test_system_exit_in_command(base_app, capsys): + """Test raising SystemExit from a command""" + import types + + def do_system_exit(self, _): + raise SystemExit + setattr(base_app, 'do_system_exit', types.MethodType(do_system_exit, base_app)) + + stop = base_app.onecmd_plus_hooks('system_exit') + assert stop + def test_output_redirection(base_app): fd, filename = tempfile.mkstemp(prefix='cmd2_test', suffix='.txt') os.close(fd) |