diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-03-18 02:46:51 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-03-18 02:46:51 -0400 |
commit | cafdc1cf64eccb12fba24b75c4df5cfd23f515e2 (patch) | |
tree | 3791357859036955c29c0e3868388bf8e29a4290 /tests/test_completion.py | |
parent | 0966c88329678d16af6bca496257e00ea78ed937 (diff) | |
download | cmd2-git-cafdc1cf64eccb12fba24b75c4df5cfd23f515e2.tar.gz |
Backing up work
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r-- | tests/test_completion.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py index 9f16e736..acb7d405 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -353,13 +353,13 @@ def test_default_to_shell_completion(cmd2_app, request): def test_path_completion_cwd(): # Run path complete with no path and no search text text = '' - line = 'shell ls {}'.format(text) + line = 'shell ls ' endidx = len(line) begidx = endidx - len(text) completions_empty = path_complete(text, line, begidx, endidx) # Run path complete with path set to the CWD - cwd = os.getcwd() + cwd = os.getcwd() + os.path.sep line = 'shell ls {}'.format(cwd) endidx = len(line) begidx = endidx - len(text) @@ -369,6 +369,15 @@ def test_path_completion_cwd(): assert completions_empty == completions_cwd assert completions_cwd +def test_path_completion_invalid_syntax(): + text = '' + line = 'shell ls ~' + endidx = len(line) + begidx = endidx + + # Can't have a ~ without a separating slash + assert path_complete(text, line, begidx, endidx) == [] + def test_path_completion_doesnt_match_wildcards(request): test_dir = os.path.dirname(request.module.__file__) @@ -386,19 +395,19 @@ def test_path_completion_user_expansion(): # Run path with just a tilde 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) # Run path complete on the user's home directory - user_dir = os.path.expanduser('~') - if sys.platform.startswith('win'): - line = 'shell dir {}'.format(user_dir) - else: - line = 'shell ls {}'.format(user_dir) + user_dir = os.path.expanduser('~') + os.path.sep + + line = 'shell {} {}'.format(cmd, user_dir) endidx = len(line) begidx = endidx - len(text) completions_home = path_complete(text, line, begidx, endidx) |