napari_plugin_engine/_testsupport.py
def add_implementation(test_plugin_manager):
    """Return a decorator that adds a HookImplementation to test_plugin_manager."""

    def addimpl(
        function=None,
        *,
        specname=None,
        tryfirst=False,
        trylast=False,
        hookwrapper=False,
    ):
        def wrap(func):
            project = test_plugin_manager.project_name
            HookImplementationMarker(project)(
                tryfirst=tryfirst,
                trylast=trylast,
                hookwrapper=hookwrapper,
                specname=specname,
            )(func)
            _specname = specname or func.__name__
            hook_caller = getattr(test_plugin_manager.hook, _specname, None)
            assert hook_caller, f"No hook with with name: {_specname}"
            opts = getattr(func, HookImplementation.format_tag(project))
            hook_caller._add_hookimpl(HookImplementation(func, **opts))
            return func

        return wrap(function) if function is not None else wrap

    return addimpl
Return a decorator that adds a HookImplementation to test_plugin_manager.
Return a decorator that adds a HookImplementation to test_plugin_manager.
Return a decorator that adds a HookImplementation to test_plugin_manager .
def add_implementation(test_plugin_manager):
    def addimpl(
        function=None,
        *,
        specname=None,
        tryfirst=False,
        trylast=False,
        hookwrapper=False,
    ):
        def wrap(func):
            project = test_plugin_manager.project_name
            HookImplementationMarker(project)(
                tryfirst=tryfirst,
                trylast=trylast,
                hookwrapper=hookwrapper,
                specname=specname,
            )(func)
            _specname = specname or func.__name__
            hook_caller = getattr(test_plugin_manager.hook, _specname, None)
            assert hook_caller, f"No hook with with name: {_specname}"
            opts = getattr(func, HookImplementation.format_tag(project))
            hook_caller._add_hookimpl(HookImplementation(func, **opts))
            return func
        return wrap(function) if function is not None else wrap
    return addimpl
def add_implementation ( test_plugin_manager ) : def addimpl ( function = None , * , specname = None , tryfirst = False , trylast = False , hookwrapper = False , ) : def wrap ( func ) : project = test_plugin_manager . project_name HookImplementationMarker ( project ) ( tryfirst = tryfirst , trylast = trylast , hookwrapper = hookwrapper , specname = specname , ) ( func ) _specname = specname or func . __name__ hook_caller = getattr ( test_plugin_manager . hook , _specname , None ) assert hook_caller , f"No hook with with name: {_specname}" opts = getattr ( func , HookImplementation . format_tag ( project ) ) hook_caller . _add_hookimpl ( HookImplementation ( func , ** opts ) ) return func return wrap ( function ) if function is not None else wrap return addimpl
Return a decorator that adds a HookImplementation to test_plugin_manager.
Return a decorator that adds a HookImplementation to test_plugin_manager .
"""Return a decorator that adds a HookImplementation to test_plugin_manager."""
test_plugin_manager