MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / test_ctrl_c_at_prompt

Function test_ctrl_c_at_prompt

tests/test_cmd2.py:1184–1193  ·  view source on GitHub ↗
(say_app, monkeypatch)

Source from the content-addressed store, hash-verified

1182
1183
1184def test_ctrl_c_at_prompt(say_app, monkeypatch) -> None:
1185 read_command_mock = mock.MagicMock(name="_read_command_line")
1186 read_command_mock.side_effect = ["say hello", KeyboardInterrupt(), "say goodbye", "quit"]
1187 monkeypatch.setattr("cmd2.Cmd._read_command_line", read_command_mock)
1188
1189 say_app.cmdloop()
1190
1191 # And verify the expected output to stdout
1192 out = say_app.stdout.getvalue()
1193 assert out == "hello\n^C\ngoodbye\n"
1194
1195
1196def test_ctrl_d_at_prompt(say_app, monkeypatch) -> None:

Callers

nothing calls this directly

Calls 2

cmdloopMethod · 0.80
getvalueMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…