Skip to content

Temporary registration via context manager - #784

Closed
victorwon2001 wants to merge 2 commits into
pytest-dev:mainfrom
victorwon2001:fix/issue-52
Closed

victorwon2001 wants to merge 2 commits into
pytest-dev:mainfrom
victorwon2001:fix/issue-52

Conversation

@victorwon2001

Copy link
Copy Markdown

Summary

Add PluginManager.register_all(plugins) as a separate context manager for temporarily registering plugins. It registers each plugin in order, yields the same manager, and unregisters successful registrations in reverse order, both after normal use and on exceptions or later registration failures. Blocked registrations remain blocked, pre-existing registrations remain active, and the existing register() signature and str | None return value are unchanged. Historic hook implementations still replay saved calls as soon as they are registered; unregistering cannot undo those effects.

Tests

Added regression coverage for single, multiple, and empty plugin iterables; temporary hook dispatch, reverse cleanup, body and registration errors, blocked and pre-existing plugins, nested contexts, and historic replay. All 231 tests and all pre-commit hooks (including Ruff and mypy) passed.

Fixes #52

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Temporary registration via context manager

2 participants