Repository navigation
Keep excluding plugins registered after a subset hook caller is made - #827
Open
abhishekcpp007 wants to merge 2 commits into
Open
abhishekcpp007 wants to merge 2 commits into
abhishekcpp007 wants to merge 2 commits into
Conversation
pytest-dev#695 replaced the hasattr() check in subset_hook_caller with an intersection against the hook's current hookimpls, to handle specname. That also dropped every plugin that isn't registered yet, so a plugin passed in remove_plugins and registered after the proxy was created was called through the proxy anyway. In 1.6.0 it stayed excluded, and _SubsetHookCaller is meant to be a live view (unregistering a plugin after creation is already covered by tests). Only discard plugins that are registered and don't implement the hook. Plugins that aren't registered yet are kept, so they're excluded once they register. The specname fix from pytest-dev#695 is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
subset_hook_callerstopped excluding a plugin that gets registered after the proxy is created. This is a regression in 1.7.0 from #695.pregistered after the proxy[]['P']remove_plugins=[a, p], onlyaregistered at creation[]['P']pregistered, proxy made, then unregister + re-register[][]Cause
#695 fixed the
specnamecase by replacingwith an intersection against the hook's current
_hookimpls. That's the right check forspecname, but a plugin that isn't registered yet has no hookimpls, so it's dropped from the set, and with nothing left the function returns the plainorigcaller. Once that plugin registers, nothing excludes it._SubsetHookCalleris a live view:test_subset_hook_callerunregisters a plugin after creating it, andtest_historic_with_subset_hook_callerregisters plugins afterwards. So whether a plugin is excluded shouldn't depend on whether it was registered at the moment the proxy was built. The last row above shows the inconsistency: re-registering an excluded plugin keeps it excluded, registering it for the first time doesn't.Fix
Keep #695's intersection for registered plugins, and keep any plugin that isn't registered yet:
origshortcut work as before.specnamebehaviour from Handle specname hooks in subset callers #695 is unchanged, andtest_subset_hook_caller_with_specnamestill passes.is_registeredlookup per plugin passed in, only when the caller is created.Tests
test_subset_hook_caller_excludes_plugin_registered_latercovers both the single-plugin case and the mixed case where one of the plugins to remove is already registered.I ran
testing/(excluding the benchmark) againstsrc/pluggyfrommainand from this branch:mainruff checkandruff format(0.17.3) and mypy are clean on the changed files. Changelog entry:changelog/827.bugfix.rst.