summaryrefslogtreecommitdiff
path: root/tests/test_completion.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-05-07 21:20:11 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-05-07 21:20:11 -0400
commite52852be4d9270040d4fcb4eeabe2ca15521f48d (patch)
tree0c94818fca6e86de1c0d968ca1846f8d67792be5 /tests/test_completion.py
parent358ff2b017aff098a82fb1f41dc021c850779daf (diff)
parent46f0aed0b66f45d08ef7fa8b16f787dc79ea32b1 (diff)
downloadcmd2-git-e52852be4d9270040d4fcb4eeabe2ca15521f48d.tar.gz
Merged master and resolved conflicts in CHANGELOG
Diffstat (limited to 'tests/test_completion.py')
-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}')