diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-03 09:57:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-03 09:57:48 -0500 |
commit | 024c0fda2c3a374c006b34bd0bf251b04e16a9cb (patch) | |
tree | b9bf49a8f8889d7abffde9d28c657f770cb82bf5 /tests/test_completion.py | |
parent | 59a59233f7005491ea4187b4e8e120baa0e3905d (diff) | |
parent | 10338e46a731d5de1c388021410b0ac116ac9ebd (diff) | |
download | cmd2-git-024c0fda2c3a374c006b34bd0bf251b04e16a9cb.tar.gz |
Merge pull request #296 from python-cmd2/completion_tweaks
Completion tweaks
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r-- | tests/test_completion.py | 28 |
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 = \ { |