Skip to content

Fix unregister argument validation under optimized Python - #771

Closed
himanshu748 wants to merge 1 commit into
pytest-dev:mainfrom
himanshu748:fix/unregister-validation-762
Closed

himanshu748 wants to merge 1 commit into
pytest-dev:mainfrom
himanshu748:fix/unregister-validation-762

Conversation

@himanshu748

Copy link
Copy Markdown

Addresses #762.

Replace the two argument-validation assertions in PluginManager.unregister() with explicit exceptions:

  • TypeError when neither a plugin nor a name is supplied.
  • ValueError when an unregistered plugin object is supplied without a name.

The checks now remain active under optimized Python. Existing behavior for successful unregisters, unknown or blocked names, and conflicting name/object arguments is preserved. The docstring and changelog document the exception-type compatibility change.

Validation on CPython 3.12.14:

  • Seven new validation cases failed before the fix.
  • Full test suite: 225 passed.
  • Unregister tests under -O and -OO: 12 passed in each mode.
  • Full pre-commit run passed, including mypy; formatter changes were reread.
  • tox run -e docs passed with Sphinx warnings treated as errors.
  • Independent agent review found no blockers.

The tracked lockfile pins pytest 3.2.5, which cannot start on Python 3.12 because it imports imp. Validation used temporary upgraded local dependencies (pytest 9.1.1), then restored the lockfile and reran tests and pre-commit with UV_NO_SYNC=1. No dependency or lockfile changes are included.

AI-assisted contribution: implementation, tests, and validation were performed with Codex and independently reviewed by another agent. No manual human review is claimed.

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