Skip to content

Document resource management in parametrizing plugins - #15199

Open
tianhaotian wants to merge 1 commit into
pytest-dev:mainfrom
tianhaotian:codex/resource-plugin-example
Open

tianhaotian wants to merge 1 commit into
pytest-dev:mainfrom
tianhaotian:codex/resource-plugin-example

Conversation

@tianhaotian

Copy link
Copy Markdown

The parametrization examples do not show how a plugin can share a resource between collection-time parameter discovery and fixture execution. This adds a runnable SQLite example using pytest_configure and pytest_unconfigure, with indirect parametrization and a fixture on the plugin instance.

The plugin is registered before database initialization so cleanup also runs if initialization fails. The documentation includes the same source files exercised by the tests.

Fixes #8208.

Validation:

  • python -m pytest testing/python/metafunc.py -q: 137 passed, including cleanup after normal runs, collection-only runs, failed tests, and failed configuration.
  • Standalone example: 2 passed, with english and french parameter IDs.
  • tox -e linting: passed, including all added files.
  • Full tox -e docs: passed after rebasing onto current main, which includes the upstream Pluggy 1.7 documentation fix.

The documentation changelog entry and AUTHORS entry are included. Maintainer edits are enabled.

Developed with Codex and reviewed by the human contributor before submission. The commit credits Codex with a Co-authored-by trailer.

Add a runnable SQLite-backed plugin example sharing a connection between
pytest_generate_tests and an indirect fixture. Verify cleanup after normal
runs, collection-only runs, failed tests and failed configuration.

Fixes pytest-dev#8208

Co-authored-by: Codex <noreply@openai.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 18, 2026

This branch has not been deployed

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

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add example of resources + parametrize fixtures

1 participant