summaryrefslogtreecommitdiff
path: root/tests_isolated/test_commandset/test_commandset.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-08-13 14:19:05 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-08-13 14:20:31 -0400
commite6da8596c433f46bc337c7e8a14c7de1b0310e4c (patch)
tree09f5a3225376e26dcb03419d6243c8fc52433b07 /tests_isolated/test_commandset/test_commandset.py
parent5dd2d03ef35a3d33ff53d82c8039d68e263246ee (diff)
downloadcmd2-git-e6da8596c433f46bc337c7e8a14c7de1b0310e4c.tar.gz
Replaced choices_function / choices_method with choices_provider.
Replaced completer_function / completer_method with completer. ArgparseCompleter now always passes cmd2.Cmd or CommandSet instance as the self argument to choices_provider and completer functions. Moved basic_complete from utils into cmd2.Cmd class. Moved CompletionError to exceptions.py
Diffstat (limited to 'tests_isolated/test_commandset/test_commandset.py')
-rw-r--r--tests_isolated/test_commandset/test_commandset.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests_isolated/test_commandset/test_commandset.py b/tests_isolated/test_commandset/test_commandset.py
index bab5d536..4b2c2137 100644
--- a/tests_isolated/test_commandset/test_commandset.py
+++ b/tests_isolated/test_commandset/test_commandset.py
@@ -51,7 +51,7 @@ class CommandSetA(CommandSetBase):
self._cmd.last_result = {'args': args}
def complete_durian(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
- return utils.basic_complete(text, line, begidx, endidx, ['stinks', 'smells', 'disgusting'])
+ return self._cmd.basic_complete(text, line, begidx, endidx, ['stinks', 'smells', 'disgusting'])
elderberry_parser = cmd2.Cmd2ArgumentParser('elderberry')
elderberry_parser.add_argument('arg1')
@@ -284,7 +284,6 @@ class LoadableBase(cmd2.CommandSet):
self._cmd.pwarning('This command does nothing without sub-parsers registered')
self._cmd.do_help('cut')
-
stir_parser = cmd2.Cmd2ArgumentParser('stir')
stir_subparsers = stir_parser.add_subparsers(title='item', help='what to stir')
@@ -379,7 +378,7 @@ class LoadableVegetables(cmd2.CommandSet):
return ['quartered', 'diced']
bokchoy_parser = cmd2.Cmd2ArgumentParser(add_help=False)
- bokchoy_parser.add_argument('style', completer_method=complete_style_arg)
+ bokchoy_parser.add_argument('style', completer=complete_style_arg)
@cmd2.as_subcommand_to('cut', 'bokchoy', bokchoy_parser)
def cut_bokchoy(self, ns: argparse.Namespace):
@@ -584,7 +583,7 @@ class AppWithSubCommands(cmd2.Cmd):
return ['quartered', 'diced']
bokchoy_parser = cmd2.Cmd2ArgumentParser(add_help=False)
- bokchoy_parser.add_argument('style', completer_method=complete_style_arg)
+ bokchoy_parser.add_argument('style', completer=complete_style_arg)
@cmd2.as_subcommand_to('cut', 'bokchoy', bokchoy_parser)
def cut_bokchoy(self, _: cmd2.Statement):
@@ -634,12 +633,12 @@ class WithCompleterCommandSet(cmd2.CommandSet):
def complete_states(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
assert self is complete_states_expected_self
- return utils.basic_complete(text, line, begidx, endidx, self.states)
+ return self._cmd.basic_complete(text, line, begidx, endidx, self.states)
class SubclassCommandSetCase1(WithCompleterCommandSet):
parser = cmd2.Cmd2ArgumentParser()
- parser.add_argument('state', type=str, completer_method=WithCompleterCommandSet.complete_states)
+ parser.add_argument('state', type=str, completer=WithCompleterCommandSet.complete_states)
@cmd2.with_argparser(parser)
def do_case1(self, ns: argparse.Namespace):
@@ -648,7 +647,7 @@ class SubclassCommandSetCase1(WithCompleterCommandSet):
class SubclassCommandSetErrorCase2(WithCompleterCommandSet):
parser = cmd2.Cmd2ArgumentParser()
- parser.add_argument('state', type=str, completer_method=WithCompleterCommandSet.complete_states)
+ parser.add_argument('state', type=str, completer=WithCompleterCommandSet.complete_states)
@cmd2.with_argparser(parser)
def do_error2(self, ns: argparse.Namespace):
@@ -661,7 +660,7 @@ class SubclassCommandSetCase2(cmd2.CommandSet):
super(SubclassCommandSetCase2, self).__init__()
parser = cmd2.Cmd2ArgumentParser()
- parser.add_argument('state', type=str, completer_method=WithCompleterCommandSet.complete_states)
+ parser.add_argument('state', type=str, completer=WithCompleterCommandSet.complete_states)
@cmd2.with_argparser(parser)
def do_case2(self, ns: argparse.Namespace):
@@ -790,7 +789,7 @@ class CommandSetWithPathComplete(cmd2.CommandSet):
super(CommandSetWithPathComplete, self).__init__()
parser = argparse.ArgumentParser()
- parser.add_argument('path', nargs='+', help='paths', completer_method=cmd2.Cmd.path_complete)
+ parser.add_argument('path', nargs='+', help='paths', completer=cmd2.Cmd.path_complete)
@cmd2.with_argparser(parser)
def do_path(self, app: cmd2.Cmd, args):