Adjust completenames tests for cmd2 0.7.3+

cmd2 0.7.3 started to override Cmd.completenames with a function
taking additional parameters:

  Cmd2.completenames(self, text, line, begidx, endidx)

over the Cmd version:

  Cmd.completenames(self, text, *ignored)

With this change we adjust the override to the new signature.

Change-Id: I7b110502c20ec16c6032cce31021eee3f85255fc
Closes-Bug: #1700250
This commit is contained in:
Dirk Mueller 2017-06-24 19:12:31 +02:00
parent 8d85b1c9a4
commit 40b75d8dc2
2 changed files with 4 additions and 3 deletions

View File

@ -60,13 +60,13 @@ class InteractiveApp(cmd2.Cmd):
line_parts = shlex.split(line.parsed.raw)
self.parent_app.run_subcommand(line_parts)
def completenames(self, text, *ignored):
def completenames(self, text, line, begidx, endidx):
"""Tab-completion for command prefix without completer delimiter.
This method returns cmd style and cliff style commands matching
provided command prefix (text).
"""
completions = cmd2.Cmd.completenames(self, text, *ignored)
completions = cmd2.Cmd.completenames(self, text, line, begidx, endidx)
completions += self._complete_prefix(text)
return completions

View File

@ -31,7 +31,8 @@ class TestInteractive(base.TestBase):
def _test_completenames(self, expecteds, prefix):
app = self.make_interactive_app('hips', 'hippo', 'nonmatching')
self.assertEqual(set(app.completenames(prefix)), set(expecteds))
self.assertEqual(
set(app.completenames(prefix, '', 0, 1)), set(expecteds))
def test_cmd2_completenames(self):
# cmd2.Cmd define do_help method