# pytest_plugin

class polyfactory.pytest_plugin.FactoryFixture

  Bases: `object`

  Decorator that creates a pytest fixture from a factory

  __init__(scope: Literal['session', 'package', 'module', 'class', 'function'] | Callable[[str, Config], Literal['session', 'package', 'module', 'class', 'function']] = 'function', autouse: bool = False, name: str | None = None) → None

    Create a factory fixture decorator

    Parameters:

      - scope – Fixture scope

      - autouse – Autouse the fixture

      - name – Fixture name

  __call__(factory: type[T]) → Callable[[], type[T]]

    Call self as a function.

polyfactory.pytest_plugin.register_fixture(factory: None = None, *, scope: Literal['session', 'package', 'module', 'class', 'function'] | Callable[[str, Config], Literal['session', 'package', 'module', 'class', 'function']] = 'function', autouse: bool = False, name: str | None = None) → FactoryFixture
polyfactory.pytest_plugin.register_fixture(factory: type[T], *, scope: Literal['session', 'package', 'module', 'class', 'function'] | Callable[[str, Config], Literal['session', 'package', 'module', 'class', 'function']] = 'function', autouse: bool = False, name: str | None = None) → Callable[[], type[T]]

  A decorator that allows registering model factories as fixtures.

  Parameters:

    - factory – An optional factory class to decorate.

    - scope – Pytest scope.

    - autouse – Auto use fixture.

    - name – Fixture name.

  Returns:

    A fixture factory instance.