Skip to content

tests: add zsh completion test for Path arguments#1664

Open
konuktor1-jpg wants to merge 2 commits into
fastapi:masterfrom
konuktor1-jpg:tests/path-completion-zsh
Open

tests: add zsh completion test for Path arguments#1664
konuktor1-jpg wants to merge 2 commits into
fastapi:masterfrom
konuktor1-jpg:tests/path-completion-zsh

Conversation

@konuktor1-jpg
Copy link
Copy Markdown

@konuktor1-jpg konuktor1-jpg commented Mar 30, 2026

Adds a small regression test for zsh path completion in tests/test_completion/test_completion_path.py.

The file already had a Bash completion test, but no zsh-specific assertion. This test checks that Path completion returns the _files signal for zsh.

Tested locally with:

  • uv run pytest tests/test_completion/test_completion_path.py -q

@konuktor1-jpg
Copy link
Copy Markdown
Author

Hi! This PR is currently blocked because it has no required label, and the workflows are awaiting maintainer approval. I think bug would fit this change since it adds a regression test for existing zsh path completion behavior. Could someone please add the appropriate label and approve the workflows?

@ADiTyaRaj8969
Copy link
Copy Markdown
Contributor

Hi @konuktor1-jpg, took a look at this on Windows with the project venv and ran the full file:

tests/test_completion/test_completion_path.py
  test_script              PASSED
  test_completion_path_bash PASSED
  test_completion_path_zsh  PASSED   (new)
3 passed in 2.75s

Why the "_files" in result.stdout assertion is the right check

For a Path argument with no autocompletion callback there are no string completions to feed back, so ZshComplete.format_completion (in typer/_completion_classes.py) returns the literal string "_files" — that's the signal that tells the zsh completion script to fall back to the shell's own file-completion. Asserting on "_files" therefore verifies the path-completion code path actually reaches the fallback, which the existing bash test (which only asserts returncode == 0) does not. Useful regression coverage.

Scope

Keeping this PR to zsh-only feels right — complete_bash, complete_fish, and complete_powershell/complete_pwsh all use different fallback mechanisms (or no fallback at all, depending on the shell), so a Path-completion test for each would warrant separate, shell-specific assertions and isn't a natural fit for this PR.

Bumping for visibility — looks ready as-is.

@svlandeg svlandeg self-assigned this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants