From 6f91bea16a00f48ff6be729ed12a5920ebac3baa Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 28 May 2020 10:54:10 -0400 Subject: Removed pwarning() calls when command raises SystemExit Added unit tests --- tests/test_cmd2.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/test_cmd2.py') 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) -- cgit v1.2.1