| 1182 | |
| 1183 | |
| 1184 | def 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 | |
| 1196 | def test_ctrl_d_at_prompt(say_app, monkeypatch) -> None: |