diff options
author | Eric Lin <anselor@gmail.com> | 2018-04-17 12:04:08 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2018-04-17 12:07:24 -0400 |
commit | de471a898eecdc49addf5912d6b43aa218ee85da (patch) | |
tree | d5bf2040b7f47af018ec4f45bae386cdf61b28e1 /tests/test_autocompletion.py | |
parent | 94da51a0dd04c76cd01680926e5c020eb9932b51 (diff) | |
download | cmd2-git-de471a898eecdc49addf5912d6b43aa218ee85da.tar.gz |
Some minor tweaks to AutoCompleter handling a collection of index-based function arguments.
Added example for fully custom completion functions mixed with argparse/AutoCompleter handling
- Also demonstrates the ability to pass in a list, tuple, or dict of parameters to append to the custom completion function.
Added new test cases exercising the custom completion function calls.
Added AutoCompleter and rl_utils to the coverage report.
Diffstat (limited to 'tests/test_autocompletion.py')
-rw-r--r-- | tests/test_autocompletion.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_autocompletion.py b/tests/test_autocompletion.py index aa82adad..7f61f997 100644 --- a/tests/test_autocompletion.py +++ b/tests/test_autocompletion.py @@ -298,6 +298,28 @@ def test_autcomp_pos_after_flag(cmd2_app): cmd2_app.completion_matches == ['John Boyega" '] +def test_autcomp_custom_func_list_arg(cmd2_app): + text = 'SW_' + line = 'library show add {}'.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 == ['SW_CW', 'SW_REB', 'SW_TCW'] + + +def test_autcomp_custom_func_list_and_dict_arg(cmd2_app): + text = '' + line = 'library show add SW_REB {}'.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 == ['S01E02', 'S01E03', 'S02E01', 'S02E03'] + + |