diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-17 01:44:36 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-17 01:44:36 -0500 |
commit | 73c8e6ddababff15ca931548340558f5b20db55e (patch) | |
tree | 0e404dc26ac83ae43fb85a17fb7c8b179edbdbf5 /tests | |
parent | 697ff1ae39e8ec3f1f1a1b9a36d68c66e8d286b2 (diff) | |
download | cmd2-git-73c8e6ddababff15ca931548340558f5b20db55e.tar.gz |
Updating unit tests
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_cmd2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 49c1ba03..5433a79d 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1232,6 +1232,17 @@ def test_select_eof(select_app, monkeypatch): read_input_mock.assert_has_calls(calls) assert read_input_mock.call_count == 2 +def test_select_ctrl_c(outsim_app, monkeypatch, capsys): + # Ctrl-C during select prints ^C and raises a KeyboardInterrupt + read_input_mock = mock.MagicMock(name='read_input', side_effect=KeyboardInterrupt) + monkeypatch.setattr("cmd2.Cmd.read_input", read_input_mock) + + with pytest.raises(KeyboardInterrupt): + outsim_app.select([('Guitar', 'Electric Guitar'), ('Drums',)], 'Instrument? ') + + out = outsim_app.stdout.getvalue() + assert out.rstrip().endswith('^C') + class HelpNoDocstringApp(cmd2.Cmd): greet_parser = argparse.ArgumentParser() greet_parser.add_argument('-s', '--shout', action="store_true", help="N00B EMULATION MODE") @@ -1504,6 +1515,13 @@ def test_read_input_rawinput_false(capsys, monkeypatch): assert line == 'eof' assert not out +def test_read_command_line_eof(base_app, monkeypatch): + read_input_mock = mock.MagicMock(name='read_input', side_effect=EOFError) + monkeypatch.setattr("cmd2.Cmd.read_input", read_input_mock) + + line = base_app._read_command_line("Prompt> ") + assert line == 'eof' + def test_poutput_string(outsim_app): msg = 'This is a test' outsim_app.poutput(msg) |