summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-03 09:45:32 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-03 09:45:32 -0500
commit10338e46a731d5de1c388021410b0ac116ac9ebd (patch)
treeb9bf49a8f8889d7abffde9d28c657f770cb82bf5
parent6f054f9ea943bd5a655d3e6e4d6be5063a8f1dd9 (diff)
downloadcmd2-git-10338e46a731d5de1c388021410b0ac116ac9ebd.tar.gz
Added a few unit tests
-rw-r--r--tests/test_completion.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 6f075c67..165e4871 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -379,6 +379,25 @@ def test_path_completion_directories_only(request):
assert path_complete(text, line, begidx, endidx, dir_only=True) == ['scripts' + os.path.sep]
+def test_path_completion_syntax_err(request):
+ test_dir = os.path.dirname(request.module.__file__)
+
+ text = 'c'
+ path = os.path.join(test_dir, text)
+ line = 'shell cat " {}'.format(path)
+
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ assert path_complete(text, line, begidx, endidx) == []
+
+def test_path_completion_no_tokens():
+ text = ''
+ line = 'shell'
+ endidx = len(line)
+ begidx = endidx - len(text)
+ assert path_complete(text, line, begidx, endidx) == []
+
# List of strings used with flag and index based completion functions
food_item_strs = ['Pizza', 'Hamburger', 'Ham', 'Potato']
@@ -457,6 +476,15 @@ def test_flag_based_completion_syntax_err():
assert flag_based_complete(text, line, begidx, endidx, flag_dict) == []
+def test_flag_based_completion_no_tokens():
+ text = ''
+ line = 'list_food'
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ assert flag_based_complete(text, line, begidx, endidx, flag_dict) == []
+
+
# Dictionary used with index based completion functions
index_dict = \
{