diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-06-01 00:45:15 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-06-01 00:45:15 -0400 |
commit | eb41d46c1f6c6281e57e8b864fa4500d3509ed55 (patch) | |
tree | 0b515e33f78b45f7eefa9dd2dcbe5bcc14baa0ec /tests/test_cmd2.py | |
parent | 19a142782bc1272af870cd893fd25fc7f19c9940 (diff) | |
parent | 8d9405a1fcc2169aa039172a8e2891b839a59e6c (diff) | |
download | cmd2-git-eb41d46c1f6c6281e57e8b864fa4500d3509ed55.tar.gz |
Merge branch 'master' into hint_bug
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) |