Skip to content

Document composing pytest fixtures with a shared RequestsMock - #845

Open
Pavel-Shcherbo wants to merge 1 commit into
getsentry:masterfrom
Pavel-Shcherbo:docs/composable-pytest-fixtures
Open

Pavel-Shcherbo wants to merge 1 commit into
getsentry:masterfrom
Pavel-Shcherbo:docs/composable-pytest-fixtures

Conversation

@Pavel-Shcherbo

Copy link
Copy Markdown

When API mocks are supplied by separate pytest fixtures, nesting independent RequestsMock contexts does not combine their routes. This documents a shared function-scoped context that API-specific fixtures populate, with a runnable two-API example.

Refs #779.

The accompanying tests exercise each API fixture independently, both together in either fixture-argument order, shared instance identity, and fresh registries/call history for each test. The standard unused-response assertion remains enabled. No library behavior changes.

Validation on Python 3.14.6 / Requests 2.34.2:

  • 4 fixture-composition cases pass.
  • The Python block extracted from the README passes separately as a pytest test.
  • A separate control confirms nested independent contexts do not merge routes and that the outer context resumes after the inner context exits.
  • All applicable pinned pre-commit hooks pass for the two changed files.

The full tox/Python compatibility matrix was not run locally. These examples exercise existing behavior; they are not failing-before/passing-after library regressions.

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