We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 484930c commit 9edd091Copy full SHA for 9edd091
tests/test_cmd2.py
@@ -1191,6 +1191,18 @@ def test_ctrl_c_at_prompt(say_app, monkeypatch) -> None:
1191
assert out == 'hello\n^C\ngoodbye\n'
1192
1193
1194
+def test_ctrl_d_at_prompt(say_app, monkeypatch) -> None:
1195
+ read_command_mock = mock.MagicMock(name='_read_command_line')
1196
+ read_command_mock.side_effect = ['say hello', EOFError()]
1197
+ monkeypatch.setattr("cmd2.Cmd._read_command_line", read_command_mock)
1198
+
1199
+ say_app.cmdloop()
1200
1201
+ # And verify the expected output to stdout
1202
+ out = say_app.stdout.getvalue()
1203
+ assert out == 'hello\n\n'
1204
1205
1206
class ShellApp(cmd2.Cmd):
1207
def __init__(self, *args, **kwargs) -> None:
1208
super().__init__(*args, **kwargs)
0 commit comments