(cmd2_app)
| 511 | |
| 512 | |
| 513 | def test_path_completion_no_path(cmd2_app) -> None: |
| 514 | # Run path complete with search text that isn't preceded by a path. This should use CWD as the path. |
| 515 | text = "p" |
| 516 | line = f"shell ls {text}" |
| 517 | endidx = len(line) |
| 518 | begidx = endidx - len(text) |
| 519 | completions_no_text = cmd2_app.path_complete(text, line, begidx, endidx) |
| 520 | |
| 521 | # Run path complete with path set to the CWD |
| 522 | text = os.getcwd() + os.path.sep + text |
| 523 | line = f"shell ls {text}" |
| 524 | endidx = len(line) |
| 525 | begidx = endidx - len(text) |
| 526 | completions_cwd = cmd2_app.path_complete(text, line, begidx, endidx) |
| 527 | |
| 528 | # To compare matches, strip off the CWD from the front of completions_cwd (leave the 's'). |
| 529 | stripped_paths = [CompletionItem(value=item.text.replace(text[:-1], "", 1)) for item in completions_cwd] |
| 530 | completions_cwd = dataclasses.replace(completions_cwd, items=stripped_paths) |
| 531 | |
| 532 | # Verify that the first test gave results for entries in the cwd |
| 533 | assert completions_no_text == completions_cwd |
| 534 | assert completions_cwd |
| 535 | |
| 536 | |
| 537 | @pytest.mark.skipif(sys.platform == "win32", reason="this only applies on systems where the root directory is a slash") |
nothing calls this directly
no test coverage detected
searching dependent graphs…