skillfed

async-factory-boy

factory_boy extension with asynchronous ORM support

async-factory-boy v1.0.1 199.2K downloads/30d#9,713 on PyPI25
Permissive license MIT DORMANT released

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-boy

uv

uv add async-factory-boy

poetry

poetry add async-factory-boy

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Tags

async factory fixturesfactory_boy async ormsqlalchemy async test factorytortoise orm test fixturesasync database test data generationasync factory patternorm async factory
async-testingorm-fixturesfactory-pattern

More Python Modules packages