summaryrefslogtreecommitdiff
path: root/tests/test_completion.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/test_completion.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/test_completion.py')
-rwxr-xr-xtests/test_completion.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 48a055d0..ac4216bb 100755
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -65,13 +65,13 @@ class CompletionsExample(cmd2.Cmd):
cmd2.Cmd.__init__(self, multiline_commands=['test_multiline'])
self.foo = 'bar'
self.add_settable(utils.Settable('foo', str, description="a settable param",
- completer_method=CompletionsExample.complete_foo_val))
+ completer=CompletionsExample.complete_foo_val))
def do_test_basic(self, args):
pass
def complete_test_basic(self, text, line, begidx, endidx):
- return utils.basic_complete(text, line, begidx, endidx, food_item_strs)
+ return self.basic_complete(text, line, begidx, endidx, food_item_strs)
def do_test_delimited(self, args):
pass
@@ -84,7 +84,7 @@ class CompletionsExample(cmd2.Cmd):
def complete_test_sort_key(self, text, line, begidx, endidx):
num_strs = ['2', '11', '1']
- return utils.basic_complete(text, line, begidx, endidx, num_strs)
+ return self.basic_complete(text, line, begidx, endidx, num_strs)
def do_test_raise_exception(self, args):
pass
@@ -96,7 +96,7 @@ class CompletionsExample(cmd2.Cmd):
pass
def complete_test_multiline(self, text, line, begidx, endidx):
- return utils.basic_complete(text, line, begidx, endidx, sport_item_strs)
+ return self.basic_complete(text, line, begidx, endidx, sport_item_strs)
def do_test_no_completer(self, args):
"""Completing this should result in completedefault() being called"""
@@ -541,7 +541,7 @@ def test_basic_completion_single(cmd2_app):
endidx = len(line)
begidx = endidx - len(text)
- assert utils.basic_complete(text, line, begidx, endidx, food_item_strs) == ['Pizza']
+ assert cmd2_app.basic_complete(text, line, begidx, endidx, food_item_strs) == ['Pizza']
def test_basic_completion_multiple(cmd2_app):
text = ''
@@ -549,7 +549,7 @@ def test_basic_completion_multiple(cmd2_app):
endidx = len(line)
begidx = endidx - len(text)
- matches = sorted(utils.basic_complete(text, line, begidx, endidx, food_item_strs))
+ matches = sorted(cmd2_app.basic_complete(text, line, begidx, endidx, food_item_strs))
assert matches == sorted(food_item_strs)
def test_basic_completion_nomatch(cmd2_app):
@@ -558,7 +558,7 @@ def test_basic_completion_nomatch(cmd2_app):
endidx = len(line)
begidx = endidx - len(text)
- assert utils.basic_complete(text, line, begidx, endidx, food_item_strs) == []
+ assert cmd2_app.basic_complete(text, line, begidx, endidx, food_item_strs) == []
def test_delimiter_completion(cmd2_app):
text = '/home/'