summaryrefslogtreecommitdiff
path: root/tests/test_transcript.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-03-26 15:25:16 -0400
committerGitHub <noreply@github.com>2020-03-26 15:25:16 -0400
commit274a57b7aa56cd6b5dabcdc73326dd4d0e45aae3 (patch)
treecfd3150073e9f0fce61fdc18d17fb49496e66b8a /tests/test_transcript.py
parent990ec45e087aed2a9a6309db893c8a25cb3a89fd (diff)
parent38b37a98f3affe8632866177195c2c16a3ef88ed (diff)
downloadcmd2-git-274a57b7aa56cd6b5dabcdc73326dd4d0e45aae3.tar.gz
Merge pull request #910 from python-cmd2/ctrl-c-script
Ctrl-C now stops a running text script instead of just the current script command
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r--tests/test_transcript.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index 64c95b30..aa6f8c4e 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -81,6 +81,9 @@ class CmdLineApp(cmd2.Cmd):
"""Do nothing and output nothing"""
pass
+ def do_keyboard_interrupt(self, _):
+ raise KeyboardInterrupt('Interrupting this command')
+
def test_commands_at_invocation():
testargs = ["prog", "say hello", "say Gracie", "quit"]
@@ -235,6 +238,12 @@ def test_generate_transcript_stop(capsys):
_, err = capsys.readouterr()
assert err.startswith("Command 2 triggered a stop")
+ # keyboard_interrupt command should stop the loop and not run the third command
+ commands = ['help', 'keyboard_interrupt', 'set']
+ app._generate_transcript(commands, transcript_fname)
+ _, err = capsys.readouterr()
+ assert err.startswith("Interrupting this command\nCommand 2 triggered a stop")
+
@pytest.mark.parametrize('expected, transformed', [
# strings with zero or one slash or with escaped slashes means no regular