summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-23 11:30:38 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-23 11:30:54 -0400
commit3a4893ec32c6d38cad344667fead93e2eed8dc88 (patch)
tree65d6073d92769ff3f4e3fe023d47cafad6bacf73 /tests/test_cmd2.py
parentfabe4cd01b339d628ffd0b8d9b202a4a41555b8b (diff)
downloadcmd2-git-3a4893ec32c6d38cad344667fead93e2eed8dc88.tar.gz
onecmd_plus_hooks() now sets self.exit_code when a SystemExit handled
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 91815d50..e369a9cf 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -537,13 +537,16 @@ def test_system_exit_in_command(base_app, capsys):
"""Test raising SystemExit in a command"""
import types
+ exit_code = 5
+
def do_system_exit(self, _):
- raise SystemExit
+ raise SystemExit(exit_code)
setattr(base_app, 'do_system_exit', types.MethodType(do_system_exit, base_app))
stop = base_app.onecmd_plus_hooks('system_exit')
assert stop
+ assert base_app.exit_code == exit_code
def test_passthrough_exception_in_command(base_app):