MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / test_path_completion_files_and_directories

Function test_path_completion_files_and_directories

tests/test_completion.py:461–473  ·  view source on GitHub ↗

Test that directories include an ending slash and files do not.

(cmd2_app, request)

Source from the content-addressed store, hash-verified

459
460
461def test_path_completion_files_and_directories(cmd2_app, request) -> None:
462 """Test that directories include an ending slash and files do not."""
463 test_dir = os.path.dirname(request.module.__file__)
464
465 text = os.path.join(test_dir, "s")
466 line = f"shell cat {text}"
467
468 endidx = len(line)
469 begidx = endidx - len(text)
470
471 expected = [text + "cript.py", text + "cript.txt", text + "cripts" + os.path.sep]
472 completions = cmd2_app.path_complete(text, line, begidx, endidx)
473 assert completions.to_strings() == Completions.from_values(expected).to_strings()
474
475
476def test_path_completion_nomatch(cmd2_app, request) -> None:

Callers

nothing calls this directly

Calls 3

path_completeMethod · 0.80
to_stringsMethod · 0.80
from_valuesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…