factory_boy vs mixer

Python test data generation libraries compared

factory_boy and mixer both generate Python objects for tests as an alternative to hand-maintained fixtures. factory_boy centers on reusable factory definitions and build, create, or stub strategies, while mixer emphasizes generated field values and configurable backend persistence.

factory_boymixer
LanguagePythonPython
LicenseMIT—
Stars3.8k953
Forks42491
Last analyzedOct 3, 2026Oct 24, 2026

Key differences

  • factory_boy offers build, create, and stub strategies; mixer lets you configure whether generated objects are committed to a database.
  • factory_boy documents ORM integrations for Django, Mogo, MongoEngine, and SQLAlchemy; mixer also lists Flask-SQLAlchemy, Peewee, Pony, and Marshmallow.
  • factory_boy highlights subfactories, lazy attributes, sequences, and reseeding randomness; mixer highlights nested field values, custom value iterators, generator overrides, and Faker locale switching.
  • factory_boy is listed with an MIT license; mixer metadata says NOASSERTION, while its README describes the project as BSD licensed.
  • The supplied project facts list factory_boy at 3.8k stars and 424 forks, compared with mixer at 954 stars and 91 forks.
  • mixer's considerations specify Python 3.7+ and Django 3.0 and 3.1 support; factory_boy's considerations refer readers to its documentation for compatibility details.

Choose factory_boy if you…

  • need distinct build, saved-instance, and stub strategies.
  • want reusable factory definitions with per-call overrides, related objects, and sequence-based values.
  • need the listed Django, Mogo, MongoEngine, or SQLAlchemy integrations.
Read the factory_boy analysis →

Choose mixer if you…

  • want generated field values and configurable database commits.
  • need the listed Flask-SQLAlchemy, Peewee, Pony, or Marshmallow support.
  • want to customize field generators, register middleware, or switch Faker locales.
Read the mixer analysis →

Compare the numbers side by side, or add more projects

This comparison is generated with AI from the OSRepos analyses of both projects. Always check each project's repository and documentation before choosing.