summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-28 10:41:48 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-28 10:41:48 -0400
commit9dc01864df378ae128d0292e7f18e6b5e81765c4 (patch)
treecbda7b0153105da4e8304f5fa6950434e8f63bb4 /tests
parent52aad8b80a619b13a67f9306b621df9c0e02bacf (diff)
downloadcmd2-git-9dc01864df378ae128d0292e7f18e6b5e81765c4.tar.gz
Changed default behavior of runcmds_plus_hooks() to not stop when Ctrl-C is pressed and instead run the next command in its list.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_cmd2.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index b09141c9..2ff70055 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -422,19 +422,19 @@ def test_runcmds_plus_hooks_ctrl_c(base_app, capsys):
setattr(base_app, 'do_keyboard_interrupt', types.MethodType(do_keyboard_interrupt, base_app))
- # Default behavior is to stop command loop on Ctrl-C
+ # Default behavior is to not stop runcmds_plus_hooks() on Ctrl-C
base_app.history.clear()
base_app.runcmds_plus_hooks(['help', 'keyboard_interrupt', 'shortcuts'])
out, err = capsys.readouterr()
- assert err.startswith("Interrupting this command")
- assert len(base_app.history) == 2
+ assert not err
+ assert len(base_app.history) == 3
- # Ctrl-C should not stop command loop in this case
+ # Ctrl-C should stop runcmds_plus_hooks() in this case
base_app.history.clear()
- base_app.runcmds_plus_hooks(['help', 'keyboard_interrupt', 'shortcuts'], stop_on_keyboard_interrupt=False)
+ base_app.runcmds_plus_hooks(['help', 'keyboard_interrupt', 'shortcuts'], stop_on_keyboard_interrupt=True)
out, err = capsys.readouterr()
- assert not err
- assert len(base_app.history) == 3
+ assert err.startswith("Interrupting this command")
+ assert len(base_app.history) == 2
def test_relative_run_script(base_app, request):