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

Function test_path_completion_no_text

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

Source from the content-addressed store, hash-verified

487
488
489def test_path_completion_no_text(cmd2_app) -> None:
490 # Run path complete with no search text which should show what's in cwd
491 text = ""
492 line = f"shell ls {text}"
493 endidx = len(line)
494 begidx = endidx - len(text)
495 completions_no_text = cmd2_app.path_complete(text, line, begidx, endidx)
496
497 # Run path complete with path set to the CWD
498 text = os.getcwd() + os.path.sep
499 line = f"shell ls {text}"
500 endidx = len(line)
501 begidx = endidx - len(text)
502 completions_cwd = cmd2_app.path_complete(text, line, begidx, endidx)
503
504 # To compare matches, strip off the CWD from the front of completions_cwd.
505 stripped_paths = [CompletionItem(value=item.text.replace(text, "", 1)) for item in completions_cwd]
506 completions_cwd = dataclasses.replace(completions_cwd, items=stripped_paths)
507
508 # Verify that the first test gave results for entries in the cwd
509 assert completions_no_text == completions_cwd
510 assert completions_cwd
511
512
513def test_path_completion_no_path(cmd2_app) -> None:

Callers

nothing calls this directly

Calls 2

CompletionItemClass · 0.90
path_completeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…