factory_boy review
An open-source Python library for structured ORM fixtures and related test objects.
Reviewed by iTechGuides Editors · Editorial team · Updated Oct 2026
factory_boy is an open-source Python library for developers who need repeatable test objects and application fixtures. Instead of maintaining static fixture files, teams define declarative factories for Python objects and customize fields as needed. It is particularly suited to projects using Django, MongoEngine, Mogo, or SQLAlchemy, with support for related objects and foreign-key generation.
Its main strength is the depth of its factory model. Developers can choose build, create, or stub instantiation strategies, generate objects in batches, and compose nested factories with SubFactory. Faker integration adds realistic randomized values, while ORM-specific factory classes can save generated objects through the relevant framework or database session. This makes factory_boy a practical fit for tests that need connected object graphs rather than isolated records.
The trade-off is focus. factory_boy is primarily an application-fixture library, with deployment centered on self-hosted use inside a Python codebase. It fits teams that want programmable, framework-aware test data generation and are comfortable defining factories in code. Teams seeking a standalone platform for broad data operations, hosted workflows, or a wider range of database connectors should choose a different category of tool. For Django and supported Python ORM projects, factory_boy keeps test-object creation close to the models and sessions that consume it.
factory_boy pros and cons
- Where it wins
- Declarative factories support nested and related objects.
- Build, create, stub, and batch generation strategies.
- Integrates with Django, MongoEngine, Mogo, SQLAlchemy, and Faker.
- Where it doesn't
- Focused on Python application fixtures rather than standalone data generation.
- Requires self-hosted use within a development environment.
- Database support centers on selected Python ORM integrations.
factory_boy fact sheet, pricing and score →
Advertiser disclosure: iTechGuides is reader-supported. Vendors can pay for top positions in our rankings and for a place on other products' pages, and we may earn a commission when you click some links. Bought places stand at the number bought; this page and our disclosure say so. Paying vendors may get a fuller, more detailed review from our editors, and that review can change their score. How we rank.
Last updated · How we research and update