-
Notifications
You must be signed in to change notification settings - Fork 125
Temporary registration via context manager #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@tgoodlet sounds potentially practical, but also not something we can expose in pytest (due to lack of plugin dependency maangement) |
Nothing against the proposal, I'm a bit curious about the use case: the temporary plugin registration is for testing, or to be used during production? |
@RonnyPfannschmidt oh yeah? Is there a way we can fix that? @nicoddemus I was thinking both. It allows a plugin creator to overload hooks temporarily. If a hook is called multiple times under different contexts it may come in handy. One example from |
Thanks for the use case @goodboy ! I think it is perfectly fine to add this. 😁 I wonder though, we might implement this functionality using just with pm.register(plugin):
# plugin will be unregistered after the end of the block I think it is pretty readable, backward compatible and we don't need to add a new API. It doesn't let you register multiple plugins in a single call, unless we change the |
@nicoddemus to make this backwards compat won't we need to still return the plugin name? If so then I'm not sure how we can use I guess it's possible but seems a bit confusing and messy to implement. |
We can declare a single Plugin that depends in more plugins, but AS things are, pluggy is unaware of dependent plugins |
Oh I didn't realize we returned the plugin name, I assumed we returned Scratch that idea then, it would be too complicated to support it. |
@nicoddemus @hpk42 i do wonder if it would make sense to change the registration api and do major releases of pluggy/pytest |
You mean to no longer return the plugin name from |
@nicoddemus that would be one example, before i propose an actual api change i want to survey use-cases better also we do have many internals that are scarry and di things the messy way (blocking plugins, registering plugins and naming plugins are all interspersed in a "fun" dictionary that simply makes a mess |
This is a proposal for a very simple new feature. I actually implemented it in a side project pysipp and was thinking it was something we could add to the
PluginManger
.The jist of it is adding a way to temporarily register plugins using a context manager api:
So it would basically just be adding
PluginManager.register_all()
(or whatever name you guys think is best) method that is a simple wrapper aroundregister
/unregister
.The text was updated successfully, but these errors were encountered: