diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-08-07 20:29:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 20:29:50 -0400 |
commit | cc3d5cd210902e899ee34cd4f71c344fdc075ecb (patch) | |
tree | eccdd7cfb4c189cdb834a2939a89a5cd47e7bfc2 /tests/test_cmd2.py | |
parent | 89a5a646ffa2f72154b932f0b2dbf23fd87866e3 (diff) | |
parent | a14c63d9c8edb8c07a8402a507993a6fed2068f8 (diff) | |
download | cmd2-git-cc3d5cd210902e899ee34cd4f71c344fdc075ecb.tar.gz |
Merge pull request #754 from python-cmd2/no_tab_select
Disabled tab completion during a select call
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-x | tests/test_cmd2.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 1ba10f6b..ae02f16b 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -639,7 +639,7 @@ def _expected_no_editor_error(): expected_text = normalize(""" EXCEPTION of type '{}' occurred with message: 'Please use 'set editor' to specify your text editing program of choice.' -To enable full traceback, run the following command: 'set debug true' +To enable full traceback, run the following command: 'set debug true' """.format(expected_exception)) return expected_text @@ -1098,6 +1098,7 @@ def test_select_invalid_option_too_big(select_app): arg = 'Sauce? ' calls = [mock.call(arg), mock.call(arg)] m.assert_has_calls(calls) + assert m.call_count == 2 # And verify the expected output to stdout assert out == expected @@ -1122,6 +1123,7 @@ def test_select_invalid_option_too_small(select_app): arg = 'Sauce? ' calls = [mock.call(arg), mock.call(arg)] m.assert_has_calls(calls) + assert m.call_count == 2 # And verify the expected output to stdout assert out == expected @@ -1181,6 +1183,19 @@ Charm us with the {}... # And verify the expected output to stdout assert out == expected +def test_select_eof(select_app): + # Ctrl-D during select causes an EOFError that just reprompts the user + m = mock.MagicMock(name='input', side_effect=[EOFError, 2]) + builtins.input = m + + food = 'fish' + out, err = run_cmd(select_app, "eat {}".format(food)) + + # Make sure our mock was called exactly twice with the expected arguments + arg = 'Sauce? ' + calls = [mock.call(arg), mock.call(arg)] + m.assert_has_calls(calls) + assert m.call_count == 2 class HelpNoDocstringApp(cmd2.Cmd): greet_parser = argparse.ArgumentParser() |