Skip to content

Raise TypeError/ValueError from unregister() instead of assert - #772

Open
ekanshul wants to merge 1 commit into
pytest-dev:mainfrom
ekanshul:fix-762-unregister-asserts
Open

ekanshul wants to merge 1 commit into
pytest-dev:mainfrom
ekanshul:fix-762-unregister-asserts

Conversation

@ekanshul

@ekanshul ekanshul commented Oct 9, 2026

Copy link
Copy Markdown

unregister() validated its arguments with assert. Under python -O those checks disappear, so pm.unregister() returned None and pm.unregister(unregistered_plugin) returned the plugin.

Raise TypeError when neither plugin nor name is given, and ValueError when the given plugin object is not registered. The existing name= path still returns None when the name is unknown.

Fixes #762

assert is skipped under python -O, so unregister() with no arguments
returned None and unregister(unregistered_plugin) returned the plugin.
Raise TypeError when neither name nor plugin is given, and ValueError
when the given plugin is not registered.

Fixes pytest-dev#762
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.

unregister() argument validation relies on assert

1 participant