diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-07 21:45:52 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-07 21:45:52 -0400 |
commit | bb2dd69bd04f5dccff9474c018eb6b6eea74c6af (patch) | |
tree | 543f626a84ac96d97c478e4e1af185ce07831908 /tests | |
parent | f8db8b766540920de6c85a26a6740170455b9354 (diff) | |
download | cmd2-git-bb2dd69bd04f5dccff9474c018eb6b6eea74c6af.tar.gz |
Moved all custom argparse classes intended for normal development to argparse_custom.py.
Lazy loading AutoCompleter in cmd2 instance methods to allow argparse_completer.py to import
cmd2.Cmd class. This Architecture makes more sense because AutoCompleter depends on cmd2.Cmd.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_argparse_completer.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py index a3fa6a59..6e092619 100644 --- a/tests/test_argparse_completer.py +++ b/tests/test_argparse_completer.py @@ -9,9 +9,8 @@ from typing import List import pytest import cmd2 -from cmd2 import with_argparser -from cmd2.argparse_completer import CompletionItem, is_potential_flag, DEFAULT_DESCRIPTIVE_HEADER -from cmd2.argparse_custom import Cmd2ArgParser +from cmd2 import with_argparser, Cmd2ArgParser, CompletionItem +from cmd2.argparse_completer import is_potential_flag, DEFAULT_DESCRIPTIVE_HEADER from cmd2.utils import StdSim, basic_complete from .conftest import run_cmd, complete_tester @@ -208,6 +207,7 @@ def test_autocomp_positional_choices_completion(ac_app, pos, text, completions): first_match = complete_tester(text, line, begidx, endidx, ac_app) assert first_match is not None and ac_app.completion_matches == sorted(completions, key=ac_app.matches_sort_key) + @pytest.mark.parametrize('flag, text, completions', [ ('-f', '', completions_from_function), ('--function', 'f', ['function', 'fairly']), @@ -222,6 +222,7 @@ def test_autocomp_flag_completers(ac_app, flag, text, completions): first_match = complete_tester(text, line, begidx, endidx, ac_app) assert first_match is not None and ac_app.completion_matches == sorted(completions, key=ac_app.matches_sort_key) + @pytest.mark.parametrize('pos, text, completions', [ (1, '', completions_from_function), (1, 'c', ['completions', 'complete']), @@ -338,6 +339,7 @@ Hint: ''' + def test_autocomp_hint_no_help(ac_app, capsys): text = '' line = 'hint foo {}'.format(text) @@ -503,6 +505,7 @@ Hint: # # Since -- appeared before the -- being completed, nothing should be completed # assert complete_tester(text, line, begidx, endidx, cmd2_app) is None + def test_is_potential_flag(): parser = Cmd2ArgParser() |