API Refernce¶
- class concurrent_fixture_group.ConcurrentFixtureGroup(name: str, *, autouse: bool = False, scope: ... = 'function', parent_fixture_name: str | None = None, fixture_namespace: dict[str, Any] | int = 1, autoskip: bool = True, parent_fixture_factory: Callable[..., Any] = ..., child_fixture_factory: Callable[..., Any] = ...)[source]¶
A group of fixtures that can be run concurrently. Aggregates “child fixtures” into tasks that are run in parallel.
- Parameters:
name – the name of the group
autouse – whether to automatically use this fixture, equivalent to the autouse parameter on pytest fixtures
scope – the scope of the fixture group, equivalent to the scope parameter on pytest fixtures
parent_fixture_name – the name of the virtual parent fixture. This name will be injected into the caller’s global namespace. If unassigned, will choose an underscored name. See Namespace Injection for more information.
fixture_namespace – the namespace to inject into the caller’s global namespace. See Namespace Injection for more information. If set to an integer, will use the global namespace of a frame in the callstack with that number. Default is to use the caller’s global namespace.
autoskip – whether to automatically skip all child fixtures, see Skipping Child Fixtures for more information.
parent_fixture_factory – the factory function to create the parent fixture. Defaults to pytest-asyncio’s
fixture.child_fixture_factory – the factory function to create the child fixtures. Defaults to pytests’s
fixture.
- fixture(func, *, name: str | None = None, autoskip: bool | None = None, factory: Callable[..., Any] = ...)[source]¶
- fixture(*, name: str | None = None, autoskip: bool | None = None, factory: Callable[..., Any] = ...)
Register a fixture function to the group. Should be used as a decorator.
- Parameters:
func – the fixture function. Must be an async function that either returns a value or yields once.
name – the name of the fixture. If assigned, will inject the new name into the group instance’s
fixture_namespace. If unassigned no injection will take place, the fixture will be returned and replace the decorated function.autoskip – whether to automatically use this fixture whenever the parent is used. Defaults to the group instance’s
autoskip. see Skipping Child Fixtures for more information.factory – the factory function to create the fixture. Defaults to the group instance’s
child_fixture_factory.
- Returns:
the decorated function if
nameis assigned, otherwise the fixture that should replace the function by decorator.