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

    def addspec(function=None, *, firstresult=False, historic=False):
        def wrap(func):
            project = test_plugin_manager.project_name
            test_hookspec = HookSpecificationMarker(project)
            test_hookspec(firstresult=firstresult, historic=historic)(func)
            name = func.__name__
            namespace = type("Hook", (), {name: func})
            assert not hasattr(
                test_plugin_manager.hook, name
            ), f"Hook already exists with name: {name}"
            opts = getattr(func, HookSpecification.format_tag(project))
            hook_caller = HookCaller(
                name, test_plugin_manager._hookexec, namespace, opts
            )
            setattr(test_plugin_manager.hook, name, hook_caller)

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

    return addspec
Return a decorator that adds a HookSpecification to test_plugin_manager.
Return a decorator that adds a HookSpecification to test_plugin_manager.
Return a decorator that adds a HookSpecification to test_plugin_manager .
def add_specification(test_plugin_manager):
    def addspec(function=None, *, firstresult=False, historic=False):
        def wrap(func):
            project = test_plugin_manager.project_name
            test_hookspec = HookSpecificationMarker(project)
            test_hookspec(firstresult=firstresult, historic=historic)(func)
            name = func.__name__
            namespace = type("Hook", (), {name: func})
            assert not hasattr(
                test_plugin_manager.hook, name
            ), f"Hook already exists with name: {name}"
            opts = getattr(func, HookSpecification.format_tag(project))
            hook_caller = HookCaller(
                name, test_plugin_manager._hookexec, namespace, opts
            )
            setattr(test_plugin_manager.hook, name, hook_caller)
        return wrap(function) if function is not None else wrap
    return addspec
def add_specification ( test_plugin_manager ) : def addspec ( function = None , * , firstresult = False , historic = False ) : def wrap ( func ) : project = test_plugin_manager . project_name test_hookspec = HookSpecificationMarker ( project ) test_hookspec ( firstresult = firstresult , historic = historic ) ( func ) name = func . __name__ namespace = type ( "Hook" , ( ) , { name : func } ) assert not hasattr ( test_plugin_manager . hook , name ) , f"Hook already exists with name: {name}" opts = getattr ( func , HookSpecification . format_tag ( project ) ) hook_caller = HookCaller ( name , test_plugin_manager . _hookexec , namespace , opts ) setattr ( test_plugin_manager . hook , name , hook_caller ) return wrap ( function ) if function is not None else wrap return addspec
Return a decorator that adds a HookSpecification to test_plugin_manager.
Return a decorator that adds a HookSpecification to test_plugin_manager .
"""Return a decorator that adds a HookSpecification to test_plugin_manager."""
test_plugin_manager