summaryrefslogtreecommitdiff
path: root/tests/test_completion.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-18 14:07:12 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-18 14:07:12 -0400
commitd41fd7cb3c1bd80c61171ce5484547586c5789ba (patch)
tree6b2656837d4fb96b46843f14b3e0eb59c2c18ec2 /tests/test_completion.py
parent4f63fdfdc9bf52e99220cd4b1a7a09ea5d78b239 (diff)
downloadcmd2-git-d41fd7cb3c1bd80c61171ce5484547586c5789ba.tar.gz
Fixed how we complete ~
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r--tests/test_completion.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index a51a4e1f..697e68d4 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -382,16 +382,29 @@ 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_user_expansion():
+def test_path_completion_just_tilde():
# Run path with just a tilde
text = ''
+ line = 'shell fake ~'
+ endidx = len(line)
+ begidx = endidx - len(text)
+ completions_tilde = path_complete(text, line, begidx, endidx)
+
+ # Path complete should return a slash
+ assert completions_tilde == [os.path.sep]
+
+def test_path_completion_user_expansion():
+ # Run path with a tilde and a slash
+ text = ''
if sys.platform.startswith('win'):
- line = 'shell dir ~{}'.format(text)
+ cmd = 'dir'
else:
- line = 'shell ls ~{}'.format(text)
+ cmd = 'ls'
+
+ line = 'shell {} ~{}'.format(cmd, os.path.sep)
endidx = len(line)
begidx = endidx - len(text)
- completions_tilde = path_complete(text, line, begidx, endidx)
+ completions_tilde_slash = path_complete(text, line, begidx, endidx)
# Run path complete on the user's home directory
user_dir = os.path.expanduser('~')
@@ -404,7 +417,7 @@ def test_path_completion_user_expansion():
completions_home = path_complete(text, line, begidx, endidx)
# Verify that the results are the same in both cases
- assert completions_tilde == completions_home
+ assert completions_tilde_slash == completions_home
def test_path_completion_directories_only(request):
test_dir = os.path.dirname(request.module.__file__)