summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-18 15:09:10 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-18 15:09:10 -0400
commit083080b5ae00a2a01b009bea85cd03a34cacf133 (patch)
tree8943d62abcc30d325061041788541fba577e0692 /tests
parent7dec84f48dac404ff236fcea704a766dffa588a4 (diff)
downloadcmd2-git-083080b5ae00a2a01b009bea85cd03a34cacf133.tar.gz
Increased test coverage
Diffstat (limited to 'tests')
-rw-r--r--tests/test_completion.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index af903794..f749f084 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -382,6 +382,15 @@ def test_path_completion_doesnt_match_wildcards(request):
# Currently path completion doesn't accept wildcards, so will always return empty results
assert path_complete(text, line, begidx, endidx) == []
+def test_path_completion_invalid_syntax():
+ # Test a missing separator between a ~ and path
+ text = ''
+ line = 'shell fake ~Desktop'
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ assert path_complete(text, line, begidx, endidx) == []
+
def test_path_completion_just_tilde():
# Run path with just a tilde
text = ''
@@ -403,14 +412,14 @@ def test_path_completion_user_expansion():
line = 'shell {} ~{}'.format(cmd, os.path.sep)
endidx = len(line)
- begidx = endidx
+ begidx = endidx - len(text)
completions_tilde_slash = path_complete(text, line, begidx, endidx)
# Run path complete on the user's home directory
user_dir = os.path.expanduser('~') + os.path.sep
line = 'shell {} {}'.format(cmd, user_dir)
endidx = len(line)
- begidx = endidx
+ begidx = endidx - len(text)
completions_home = path_complete(text, line, begidx, endidx)
# Verify that the results are the same in both cases