summaryrefslogtreecommitdiff
path: root/tests/test_completion.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-19 13:08:43 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-19 13:08:43 -0400
commit0310ec70ddccfc3ca3563aaa8e1f62114462c228 (patch)
tree02991e19c2eefdb8745edf66ce758c31fbc09db0 /tests/test_completion.py
parentc2a3f6770e587b6203ae8b843f64a7135e605b1b (diff)
downloadcmd2-git-0310ec70ddccfc3ca3563aaa8e1f62114462c228.tar.gz
Unit test for cursor right after closing quote
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r--tests/test_completion.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 3d4b0222..03158523 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -194,6 +194,33 @@ def test_cmd2_help_completion_nomatch(cmd2_app):
begidx = endidx - len(text)
assert cmd2_app.complete_help(text, line, begidx, endidx) == []
+
+def test_complete_cursor_by_closing_quote(cmd2_app):
+ text = ''
+ line = 'fake ""'
+ endidx = len(line)
+ begidx = endidx - len(text)
+ state = 0
+
+ def get_line():
+ return line
+
+ def get_begidx():
+ return begidx
+
+ def get_endidx():
+ return endidx
+
+ with mock.patch.object(readline, 'get_line_buffer', get_line):
+ with mock.patch.object(readline, 'get_begidx', get_begidx):
+ with mock.patch.object(readline, 'get_endidx', get_endidx):
+ # Run the readline tab-completion function with readline mocks in place
+ first_match = cmd2_app.complete(text, state)
+
+ # If the cursor is right after a closing quote, then a space is returned
+ assert first_match is not None and cmd2_app.completion_matches == [' ']
+
+
def test_shell_command_completion(cmd2_app):
if sys.platform == "win32":
text = 'calc'