Skip to content

Testing API

__all__ module-attribute

__all__ = ['given', 'then', 'when']

given

given(description: str) -> FixtureStep

then

then[**P, R](description: str) -> Callable[[Callable[P, R]], Callable[P, R]]

when

when(description: str) -> FixtureStep

Databases

Own a test database and temporarily bind its selected entities.

__test__ class-attribute instance-attribute

__test__ = False

engine instance-attribute

engine = engine

session instance-attribute

session = session

signpost instance-attribute

signpost = signpost

entities instance-attribute

entities: tuple[SQLTestEntityable, ...] = tuple(entities)

dispose instance-attribute

dispose = dispose

resources instance-attribute

resources: AsyncExitStack = AsyncExitStack()

active instance-attribute

active: bool = False

__init__

__init__(
    engine: AsyncEngine,
    session: async_sessionmaker[AsyncSession],
    signpost: S,
    entities: Sequence[SQLTestEntityable],
    *,
    dispose: bool = True,
) -> None

__aenter__ async

__aenter__() -> Self

bind

bind() -> None

drop_tables async

drop_tables() -> None

__aexit__ async

__aexit__(
    exc_type: type[BaseException] | None,
    exc: BaseException | None,
    traceback: TracebackType | None,
) -> None

Create an isolated SQLite context; supplied engines stay caller-owned.

Own a PostgreSQL container; pass configured factories for native options.

Own a MySQL container with async sessions and selected entity tables.

Reuse the MySQL context lifecycle with a MariaDB server.

Own an Oracle Free container with async sessions and selected tables.

Brokers

Own a RabbitMQ container and adapter, preserving native configuration.

Own a NATS container and adapter while retaining native configuration.

Own a Kafka container while retaining native broker and consumer options.