MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / test_shell_command_completion_shortcut

Function test_shell_command_completion_shortcut

tests/test_completion.py:358–377  ·  view source on GitHub ↗
(cmd2_app)

Source from the content-addressed store, hash-verified

356
357
358def test_shell_command_completion_shortcut(cmd2_app) -> None:
359 # Made sure ! runs a shell command and all matches start with ! since there
360 # isn't a space between ! and the shell command. Display matches won't
361 # begin with the !.
362 if sys.platform == "win32":
363 text = "!calc"
364 expected_item = CompletionItem("!calc.exe", display="calc.exe")
365 else:
366 text = "!egr"
367 expected_item = CompletionItem("!egrep", display="egrep")
368
369 expected_completions = Completions([expected_item])
370
371 line = text
372 endidx = len(line)
373 begidx = 0
374
375 completions = cmd2_app.complete(text, line, begidx, endidx)
376 assert completions.to_strings() == expected_completions.to_strings()
377 assert [item.display for item in completions] == [item.display for item in expected_completions]
378
379
380def test_shell_command_completion_does_not_match_wildcards(cmd2_app) -> None:

Callers

nothing calls this directly

Calls 4

CompletionItemClass · 0.90
CompletionsClass · 0.90
to_stringsMethod · 0.80
completeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…