Visitar URL original
Document a tested JSON response fallback for unknown URLs by ShahadatTest · Pull Request #534 · csernazs/pytest-httpserver · GitHub
Skip to content

Document a tested JSON response fallback for unknown URLs - #534

Open
ShahadatTest wants to merge 1 commit into
csernazs:masterfrom
ShahadatTest:docs/default-json-response
Open

ShahadatTest wants to merge 1 commit into
csernazs:masterfrom
ShahadatTest:docs/default-json-response

Conversation

@ShahadatTest

Copy link
Copy Markdown

Refs #383.

Document the existing catch-all handler recipe suggested in that discussion for APIs that return JSON from unknown URLs. Register a persistent fallback after specific persistent handlers, and show a known URL returning its own response and a dynamically generated unknown URL returning JSON with status 404.

The documentation explicitly explains that the fallback handles the request, so it will not be reported as unexpected by check_assertions(). This documents existing functionality; it does not add a custom no-handler response API or change unmatched-request behavior.

The how-to uses literalinclude to keep the example synchronized with an executable test. Validation on Windows / CPython 3.12.10 / pytest 9.1.1:

  • Examples suite: 28 passed, 1 existing xfailed. The new example verifies the specific handler, fallback status/body/content type, and successful assertion checking.
  • All applicable configured pre-commit hooks pass, including Ruff, Black, isort, and blacken-docs.
  • Sphinx HTML build succeeds; the new recipe and example are present. Strict builds report 50 existing warnings on both current upstream and this branch (duplicate section labels and other existing documentation configuration issues). Their normalized warning lists match exactly; this change adds no warnings.
  • git diff --check passes. No production source changes.

Prepared with assistance from OpenAI Codex; the agent wrote and executed the example and documentation checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant