summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_completion.py18
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}')