(func=None, *, scope: Union[Scope, str] = Scope.Test)
return wrapper
Decorator which will cause the wrapped function to be collected and treated as a fixture.

    Args:
        func: The wrapped function which should yield or return some data required to execute a test.
        scope: The scope of a fixture determines how long it can be cached for (and therefore how frequently
            the fixture should be regenerated).
Decorator which will cause the wrapped function to be collected and treated as a fixture.
Decorator which will cause the wrapped function to be collected and treated as a fixture .
def fixture(func=None, *, scope: Union[Scope, str] = Scope.Test):
    """
    Decorator which will cause the wrapped function to be collected and treated as a fixture.

    Args:
        func: The wrapped function which should yield or return some data required to execute a test.
        scope: The scope of a fixture determines how long it can be cached for (and therefore how frequently
            the fixture should be regenerated).
    """
    if not isinstance(scope, Scope):
        scope = Scope.from_str(scope)

    if func is None:
        return partial(fixture, scope=scope)

    # By setting is_fixture = True, the framework will know
    # that if this fixture is provided as a default arg, it
    # is responsible for resolving the value.
    path = Path(inspect.getfile(func)).absolute()
    if hasattr(func, "ward_meta"):
        func.ward_meta.is_fixture = True
        func.ward_meta.path = path
    else:
        func.ward_meta = CollectionMetadata(is_fixture=True, scope=scope, path=path)

    _DEFINED_FIXTURES.append(Fixture(func))

    @wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)

    return wrapper
def fixture ( func = None , * , scope : Union [ Scope , str ] = Scope . Test ) : if not isinstance ( scope , Scope ) : scope = Scope . from_str ( scope ) if func is None : return partial ( fixture , scope = scope ) # By setting is_fixture = True, the framework will know # that if this fixture is provided as a default arg, it # is responsible for resolving the value. path = Path ( inspect . getfile ( func ) ) . absolute ( ) if hasattr ( func , "ward_meta" ) : func . ward_meta . is_fixture = True func . ward_meta . path = path else : func . ward_meta = CollectionMetadata ( is_fixture = True , scope = scope , path = path ) _DEFINED_FIXTURES . append ( Fixture ( func ) ) @ wraps ( func ) def wrapper ( * args , * * kwargs ) : return func ( * args , * * kwargs ) return wrapper