diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-05-07 21:11:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 21:11:44 -0400 |
commit | 46f0aed0b66f45d08ef7fa8b16f787dc79ea32b1 (patch) | |
tree | 02ba0cea776cb23651353314e572f74e543e8acd /tests/test_completion.py | |
parent | 673d8a1bebcada7f0182758acfe7f65637113286 (diff) | |
parent | 47999ffd250eab4875747b32af2e7b7505212d67 (diff) | |
download | cmd2-git-46f0aed0b66f45d08ef7fa8b16f787dc79ea32b1.tar.gz |
Merge pull request #671 from python-cmd2/completion_exceptions
Improved tab completion error feedback
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r-- | tests/test_completion.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py index 23843012..158856ec 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -77,6 +77,12 @@ class CompletionsExample(cmd2.Cmd): num_strs = ['2', '11', '1'] return self.basic_complete(text, line, begidx, endidx, num_strs) + def do_test_raise_exception(self, args): + pass + + def complete_test_raise_exception(self, text, line, begidx, endidx): + raise IndexError("You are out of bounds!!") + @pytest.fixture def cmd2_app(): @@ -120,6 +126,18 @@ def test_complete_bogus_command(cmd2_app): first_match = complete_tester(text, line, begidx, endidx, cmd2_app) assert first_match is None +def test_complete_exception(cmd2_app, capsys): + text = '' + line = 'test_raise_exception {}'.format(text) + endidx = len(line) + begidx = endidx - len(text) + + first_match = complete_tester(text, line, begidx, endidx, cmd2_app) + out, err = capsys.readouterr() + + assert first_match is None + assert "IndexError" in err + def test_complete_macro(base_app, request): # Create the macro out, err = run_cmd(base_app, 'macro create fake pyscript {1}') |