summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-27 00:51:08 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-27 00:51:08 -0400
commita16cbafb6d627462531c0f6495fcabfe9e283604 (patch)
tree19e22a333d0d75cb785ae9c4aec07d005710abd1 /tests
parent6b2e9756f33636b7e53009351f474275ebfb221b (diff)
downloadcmd2-git-a16cbafb6d627462531c0f6495fcabfe9e283604.tar.gz
Added more unit tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_completion.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index e086bbd7..660cb5c0 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -35,9 +35,10 @@ def cmd2_app():
return c
-# List of strings used with basic, flag, and index based completion functions
+# List of strings used with completion functions
food_item_strs = ['Pizza', 'Hamburger', 'Ham', 'Potato', 'Space Food']
sport_item_strs = ['Bat', 'Basket', 'Basketball', 'Football']
+delimited_strs = ['/home/user/file.txt', '/home/user/prog.c', '/home/otheruser/maps']
# Dictionary used with flag based completion functions
flag_dict = \
@@ -410,6 +411,20 @@ def test_basic_completion_nomatch(cmd2_app):
assert cmd2_app.basic_complete(text, line, begidx, endidx, food_item_strs) == []
+def test_delimiter_completion(cmd2_app):
+ text = '/home/'
+ line = 'load {}'.format(text)
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ cmd2_app.delimiter_complete(text, line, begidx, endidx, delimited_strs, '/')
+
+ # Remove duplicates from display_matches and sort it. This is typically done in the display function.
+ display_set = set(cmd2_app.display_matches)
+ display_list = list(display_set)
+ display_list.sort()
+
+ assert display_list == ['otheruser', 'user']
def test_flag_based_completion_single(cmd2_app):
text = 'Pi'