diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-07 10:14:59 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-07 10:14:59 -0400 |
commit | 47999ffd250eab4875747b32af2e7b7505212d67 (patch) | |
tree | 02ba0cea776cb23651353314e572f74e543e8acd | |
parent | ee15a3df954b3a9551f29f72f097134a6a5300cc (diff) | |
download | cmd2-git-47999ffd250eab4875747b32af2e7b7505212d67.tar.gz |
Improved code coverage
-rwxr-xr-x | examples/tab_autocomp_dynamic.py | 2 | ||||
-rwxr-xr-x | examples/tab_autocompletion.py | 2 | ||||
-rw-r--r-- | tests/test_autocompletion.py | 19 |
3 files changed, 17 insertions, 6 deletions
diff --git a/examples/tab_autocomp_dynamic.py b/examples/tab_autocomp_dynamic.py index bedc9d4b..93b72442 100755 --- a/examples/tab_autocomp_dynamic.py +++ b/examples/tab_autocomp_dynamic.py @@ -69,7 +69,7 @@ class TabCompleteExample(cmd2.Cmd): setattr(director_action, argparse_completer.ACTION_ARG_CHOICES, TabCompleteExample.static_list_directors) setattr(actor_action, argparse_completer.ACTION_ARG_CHOICES, 'instance_query_actors') - # tag the file property with a custom completion function 'delimeter_complete' provided by cmd2. + # tag the file property with a custom completion function 'delimiter_complete' provided by cmd2. setattr(vid_movie_file_action, argparse_completer.ACTION_ARG_CHOICES, ('delimiter_complete', {'delimiter': '/', diff --git a/examples/tab_autocompletion.py b/examples/tab_autocompletion.py index aa28fc10..3f06a274 100755 --- a/examples/tab_autocompletion.py +++ b/examples/tab_autocompletion.py @@ -255,7 +255,7 @@ class TabCompleteExample(cmd2.Cmd): setattr(director_action, argparse_completer.ACTION_ARG_CHOICES, static_list_directors) setattr(actor_action, argparse_completer.ACTION_ARG_CHOICES, 'instance_query_actors') - # tag the file property with a custom completion function 'delimeter_complete' provided by cmd2. + # tag the file property with a custom completion function 'delimiter_complete' provided by cmd2. setattr(vid_movie_file_action, argparse_completer.ACTION_ARG_CHOICES, ('delimiter_complete', {'delimiter': '/', diff --git a/tests/test_autocompletion.py b/tests/test_autocompletion.py index a5dafd2d..005eee81 100644 --- a/tests/test_autocompletion.py +++ b/tests/test_autocompletion.py @@ -229,7 +229,7 @@ def test_autocomp_subcmd_flag_comp_list_attr(cmd2_app): assert first_match is not None and first_match == '"Gareth Edwards' -def test_autcomp_pos_consumed(cmd2_app): +def test_autocomp_pos_consumed(cmd2_app): text = '' line = 'library movie add SW_EP01 {}'.format(text) endidx = len(line) @@ -239,7 +239,7 @@ def test_autcomp_pos_consumed(cmd2_app): assert first_match is None -def test_autcomp_pos_after_flag(cmd2_app): +def test_autocomp_pos_after_flag(cmd2_app): text = 'Joh' line = 'video movies add -d "George Lucas" -- "Han Solo" PG "Emilia Clarke" "{}'.format(text) endidx = len(line) @@ -250,7 +250,7 @@ def test_autcomp_pos_after_flag(cmd2_app): cmd2_app.completion_matches == ['John Boyega" '] -def test_autcomp_custom_func_list_arg(cmd2_app): +def test_autocomp_custom_func_list_arg(cmd2_app): text = 'SW_' line = 'library show add {}'.format(text) endidx = len(line) @@ -261,7 +261,7 @@ def test_autcomp_custom_func_list_arg(cmd2_app): cmd2_app.completion_matches == ['SW_CW', 'SW_REB', 'SW_TCW'] -def test_autcomp_custom_func_list_and_dict_arg(cmd2_app): +def test_autocomp_custom_func_list_and_dict_arg(cmd2_app): text = '' line = 'library show add SW_REB {}'.format(text) endidx = len(line) @@ -272,6 +272,17 @@ def test_autcomp_custom_func_list_and_dict_arg(cmd2_app): cmd2_app.completion_matches == ['S01E02', 'S01E03', 'S02E01', 'S02E03'] +def test_autocomp_custom_func_dict_arg(cmd2_app): + text = '/home/user/' + line = 'video movies load {}'.format(text) + endidx = len(line) + begidx = endidx - len(text) + + first_match = complete_tester(text, line, begidx, endidx, cmd2_app) + assert first_match is not None and \ + cmd2_app.completion_matches == ['/home/user/another.db', '/home/user/file space.db', '/home/user/file.db'] + + def test_argparse_remainder_flag_completion(cmd2_app): import cmd2 import argparse |