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

Function test_complete_macro

tests/test_completion.py:259–275  ·  view source on GitHub ↗
(base_app, request)

Source from the content-addressed store, hash-verified

257
258
259def test_complete_macro(base_app, request) -> None:
260 # Create the macro
261 out, _err = run_cmd(base_app, "macro create fake run_pyscript {1}")
262 assert out == normalize("Macro 'fake' created")
263
264 # Macros do path completion
265 test_dir = os.path.dirname(request.module.__file__)
266
267 text = os.path.join(test_dir, "s")
268 line = f"fake {text}"
269
270 endidx = len(line)
271 begidx = endidx - len(text)
272
273 expected = [text + "cript.py", text + "cript.txt", text + "cripts" + os.path.sep]
274 completions = base_app.complete(text, line, begidx, endidx)
275 assert completions.to_strings() == Completions.from_values(expected).to_strings()
276
277
278def test_default_str_sort_key(cmd2_app) -> None:

Callers

nothing calls this directly

Calls 5

run_cmdFunction · 0.85
normalizeFunction · 0.85
to_stringsMethod · 0.80
from_valuesMethod · 0.80
completeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…