pytest-dev / pluggy

A minimalist production ready plugin system
https://pluggy.readthedocs.io/en/latest/
MIT License
1.24k stars 121 forks source link

Is it possible to override an existing hook with a HookCaller class? #455

Closed yakovbabich closed 10 months ago

yakovbabich commented 10 months ago

I tried to create HookCaller and to setattr but it seems like it is not working properly.

        hook_caller = HookCaller(
            name=hook_name,
            hook_execute=func(hook_name),
            spec_opts=hook.spec.opts,
            specmodule_or_class=hook.spec.namespace,
        )

        setattr(session.config.pluginmanager.hook, hook_name, hook_caller)

Also I noticed that there is rewrite_hook and I am not sure what is it for? session.config.pluginmanager.rewrite_hook.config.hook