Skip to content

Roll back plugin registration when historic replay raises - #779

Open
xiehuanyi wants to merge 2 commits into
pytest-dev:mainfrom
xiehuanyi:fix-historic-registration-rollback
Open

xiehuanyi wants to merge 2 commits into
pytest-dev:mainfrom
xiehuanyi:fix-historic-registration-rollback

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 11, 2026 •

Copy link
Copy Markdown

Related to #761.

If a historic hook implementation or its result callback raises during register(), the plugin currently remains registered with only some implementations installed. This prevents a clean retry and can leave hooks running from a failed plugin. Remove the failed registration before propagating the original exception. Preserve unrelated registered plugins and specifications added by user code during replay.

Regression coverage includes implementation and result-callback failures, RuntimeError and KeyboardInterrupt, retry after failure, validation against a specification introduced during replay, and preservation of a replacement plugin installed under the same name during failed replay.

Validation:

  • Five regression cases fail on the original source.
  • Full suite: 224 passed on CPython 3.15.
  • All pre-commit hooks pass, including mypy.
  • PluginManager line and branch coverage: 100%.

Tests use PYTHONPATH=src uv run --no-default-groups --with 'pytest>=8' --with 'pytest-benchmark>=4' pytest -q: the checked-in lock selects old test tools that cannot run on modern Python. The lock is unchanged. User callback side effects outside the failed registration are retained.

Prepared with OpenAI Codex.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants