Skip to content

Commit c05a16d

Browse files
committed
Updated command completion tests to use complete_tester().
1 parent 65f246e commit c05a16d

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tests/test_completion.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,6 @@ def cmd2_app():
219219
return CompletionsExample()
220220

221221

222-
def test_cmd2_command_completion_single(cmd2_app) -> None:
223-
text = 'he'
224-
line = text
225-
endidx = len(line)
226-
begidx = endidx - len(text)
227-
assert cmd2_app.basic_complete(text, line, begidx, endidx, cmd2_app.get_all_commands()) == ['help']
228-
229-
230222
def test_complete_command_single(cmd2_app) -> None:
231223
text = 'he'
232224
line = text
@@ -322,15 +314,21 @@ def test_cmd2_command_completion_multiple(cmd2_app) -> None:
322314
line = text
323315
endidx = len(line)
324316
begidx = endidx - len(text)
325-
assert cmd2_app.basic_complete(text, line, begidx, endidx, cmd2_app.get_all_commands()) == ['help', 'history']
317+
318+
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
319+
assert first_match is not None
320+
assert cmd2_app.completion_matches == ['help', 'history']
326321

327322

328323
def test_cmd2_command_completion_nomatch(cmd2_app) -> None:
329324
text = 'fakecommand'
330325
line = text
331326
endidx = len(line)
332327
begidx = endidx - len(text)
333-
assert cmd2_app.basic_complete(text, line, begidx, endidx, cmd2_app.get_all_commands()) == []
328+
329+
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
330+
assert first_match is None
331+
assert cmd2_app.completion_matches == []
334332

335333

336334
def test_cmd2_help_completion_single(cmd2_app) -> None:

0 commit comments

Comments
 (0)