summaryrefslogtreecommitdiff
path: root/tests/test_argparse_completer.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_argparse_completer.py')
-rw-r--r--tests/test_argparse_completer.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py
index 19ec551b..e690f90a 100644
--- a/tests/test_argparse_completer.py
+++ b/tests/test_argparse_completer.py
@@ -250,7 +250,10 @@ def test_help(ac_app, command):
@pytest.mark.parametrize('command, text, completions', [
('', 'mu', ['music ']),
('music', 'cre', ['create ']),
- ('music create', '', ['jazz', 'rock'])
+ ('music', 'creab', []),
+ ('music create', '', ['jazz', 'rock']),
+ ('music crea', 'jazz', []),
+ ('music create', 'foo', [])
])
def test_complete_help(ac_app, command, text, completions):
line = 'help {} {}'.format(command, text)
@@ -266,6 +269,26 @@ def test_complete_help(ac_app, command, text, completions):
assert ac_app.completion_matches == sorted(completions, key=ac_app.default_sort_key)
+@pytest.mark.parametrize('subcommand, text, completions', [
+ ('create', '', ['jazz', 'rock']),
+ ('create', 'ja', ['jazz ']),
+ ('create', 'foo', []),
+ ('creab', 'ja', [])
+])
+def test_subcommand_completions(ac_app, subcommand, text, completions):
+ line = 'music {} {}'.format(subcommand, text)
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ first_match = complete_tester(text, line, begidx, endidx, ac_app)
+ if completions:
+ assert first_match is not None
+ else:
+ assert first_match is None
+
+ assert ac_app.completion_matches == sorted(completions, key=ac_app.default_sort_key)
+
+
@pytest.mark.parametrize('command_and_args, text, completions', [
# Complete all flags (suppressed will not show)
('flag', '-', ['--append_const_flag', '--append_flag', '--count_flag', '--help', '--normal_flag',