summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-04-15 00:59:05 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-04-15 00:59:05 -0400
commit4233570973e12b0a850415e05aee9912cf3e2cd3 (patch)
treeaf3dc02000167a1f462c175bbcc9f92dbe457ff4 /tests
parent0f1a69f303f1339b7388a3c854b94e562db7529b (diff)
downloadcmd2-git-4233570973e12b0a850415e05aee9912cf3e2cd3.tar.gz
More unit tests and comments
Diffstat (limited to 'tests')
-rw-r--r--tests/test_completion.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 65c145ed..cb164a98 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -731,13 +731,13 @@ def test_add_opening_quote_delimited_nothing_added(cmd2_app):
cmd2_app.display_matches == expected_display
def test_add_opening_quote_delimited_quote_added(cmd2_app):
- text = '/home/oth'
+ text = '/home/user/fi'
line = 'test_delimited {}'.format(text)
endidx = len(line)
begidx = endidx - len(text)
- expected_prefix = '"/home/other user/'
- expected_display = ['maps', 'tests']
+ expected_prefix = '"/home/user/file'
+ expected_display = sorted(['file.txt', 'file space.txt'])
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
assert first_match is not None and \
@@ -759,6 +759,21 @@ def test_add_opening_quote_delimited_text_is_common_prefix(cmd2_app):
os.path.commonprefix(cmd2_app.completion_matches) == expected_prefix and \
cmd2_app.display_matches == expected_display
+def test_add_opening_quote_delimited_space_in_prefix(cmd2_app):
+ # This test when a space appears before the part of the string that is the display match
+ text = '/home/oth'
+ line = 'test_delimited {}'.format(text)
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ expected_prefix = '"/home/other user/'
+ expected_display = ['maps', 'tests']
+
+ first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
+ assert first_match is not None and \
+ os.path.commonprefix(cmd2_app.completion_matches) == expected_prefix and \
+ cmd2_app.display_matches == expected_display
+
class SubcommandsExample(cmd2.Cmd):
"""
Example cmd2 application where we a base command which has a couple subcommands