async-factory-boy
factory_boy extension with asynchronous ORM support
What it is and what it does
async_factory_boy is a factory_boy extension that wraps asynchronous ORM operations, letting you define test fixtures for SQLAlchemy and Tortoise ORM using async/await syntax. Instead of blocking database calls in your test factories, you call `await TestModelFactory.create()` or `await TestModelFactory.build()` to generate test data asynchronously.
The package works by subclassing factory_boy's Factory and providing ORM-specific variants (AsyncSQLAlchemyFactory, AsyncTortoiseFactory) that handle async session management. It integrates with factory_boy's Faker support for generating realistic field values. The single runtime dependency is factory-boy itself, making installation straightforward.
Use it for:
- Generate test data in async test suites without blocking the event loop or wrapping factories in sync wrappers.
- Build SQLAlchemy async session fixtures for pytest-asyncio or similar async test frameworks.
- Create Tortoise ORM test models in async test code without falling back to synchronous factory patterns.
- Populate test databases in async integration tests where the application code is fully async.
- Reduce boilerplate in async test setup by reusing factory definitions across multiple test modules.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extends factory_boy to generate test fixtures asynchronously for SQLAlchemy and Tortoise ORM, allowing async database operations in test factories.
Yes, if you are writing async tests for SQLAlchemy or Tortoise ORM and want to avoid sync-to-async bridging in your factories. The low install friction and permissive license are favorable. However, dormant maintenance (last release August 2023, last commit June 2024) means you should verify compatibility with your ORM versions and be prepared to fork or patch if issues arise. No known vulnerabilities.
Install
async-factory-boy on PyPI
pip
pip install async-factory-boyuv
uv add async-factory-boypoetry
poetry add async-factory-boyInstalling async-factory-boy
Before you install
Low install friction with a single dependency on factory-boy. Maintenance is dormant—last commit was 2024-06-12 and no releases since 2023-08-12—so expect no active bug fixes or feature updates, though the codebase is not archived.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal legal friction.
Quickstart
pip install async_factory_boy
from async_factory_boy.factory.sqlalchemy import AsyncSQLAlchemyFactory
class TestModelFactory(AsyncSQLAlchemyFactory):
class Meta:
model = TestModel
session = session
name = Faker("name")
test = await TestModelFactory.create()
Requires Python 3.8 or later; async/await syntax is mandatory for usage.
Verify before relying
- Whether the package works with current versions of SQLAlchemy's async API (sqlalchemy.ext.asyncio) or only legacy async patterns.
- Whether Tortoise ORM support is actively maintained or if breaking changes in Tortoise have introduced compatibility issues.
- Real-world test coverage and whether dormancy signals unresolved issues or simply stable, complete functionality.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — factory-boy |
| Maintenance | dormant — 1,098 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 199,223/month — #9,713 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: async_factory_boy-1.0.1-py2.py3-none-any.whl
Keywords: factory_boy, factory, fixtures, async, SQLAlchemy, Tortoise, async_factory_boy
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
factory-boyfactory_boy replaces static test fixtures with…
permissive · top 1,000 on PyPI
pytest-factoryboyIntegrates factory_boy with pytest to register…
permissive · top 5,000 on PyPI
mixerMixer generates test data and model instances…
permissive · top 15,000 on PyPI
tortoise-ormTortoise ORM is an async-native…
permissive · top 15,000 on PyPI
wagtail-factoriesProvides factory-boy classes for generating…
permissive · top 15,000 on PyPI
model-mommyModel Mommy generates Django model instances…
permissive · top 15,000 on PyPI
pypika-tortoiseGenerates SQL queries programmatically for…
permissive · top 15,000 on PyPI
ormarAn async ORM for Python that unifies database…
permissive · top 15,000 on PyPI
testing.common.databaseProvides base classes and utilities for…
permissive · top 5,000 on PyPI
sqlalchemy-mixinsProvides Active Record-style mixins for…
permissive · top 15,000 on PyPI