diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-04-12 22:53:22 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-04-12 22:53:22 -0400 |
commit | 05d2d2b850abc1354636ddf9148b358acc366b99 (patch) | |
tree | ae29faa2fd5958324b13b4d905fee847794192fa /tests/test_completion.py | |
parent | 95bd80efee7f4f607af4f58dec83024d5d6f78e1 (diff) | |
download | cmd2-git-05d2d2b850abc1354636ddf9148b358acc366b99.tar.gz |
Allowing the use of ~user expansion in paths
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r-- | tests/test_completion.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py index a5cec508..9d6fdc5a 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -9,6 +9,7 @@ Copyright 2017 Todd Leonhardt <todd.leonhardt@gmail.com> Released under MIT license, see LICENSE file """ import argparse +import getpass import os import sys @@ -341,25 +342,22 @@ def test_path_completion_doesnt_match_wildcards(cmd2_app, request): # Currently path completion doesn't accept wildcards, so will always return empty results assert cmd2_app.path_complete(text, line, begidx, endidx) == [] -def test_path_completion_invalid_syntax(cmd2_app): - # Test a missing separator between a ~ and path - text = '~Desktop' - line = 'shell fake {}'.format(text) - endidx = len(line) - begidx = endidx - len(text) +def test_path_completion_expand_user_dir(cmd2_app): + # Get the current user + user = getpass.getuser() - assert cmd2_app.path_complete(text, line, begidx, endidx) == [] - -def test_path_completion_just_tilde(cmd2_app): - # Run path with just a tilde - text = '~' + text = '~{}'.format(user) line = 'shell fake {}'.format(text) endidx = len(line) begidx = endidx - len(text) - completions_tilde = cmd2_app.path_complete(text, line, begidx, endidx) + completions = cmd2_app.path_complete(text, line, begidx, endidx) - # Path complete should complete the tilde with a slash - assert completions_tilde == [text + os.path.sep] + # On Windows there should be no results, since it lacks the pwd module + if sys.platform.startswith('win'): + assert completions == [] + else: + expected = text + os.path.sep + assert expected in completions def test_path_completion_user_expansion(cmd2_app): # Run path with a tilde and a slash |