CheckOps
Polyfactory
Polyfactory is an MIT-licensed Python library from the Litestar organisation that builds mock data factories from type hints for dataclasses, Pydantic, attrs, TypedDict, msgspec and ORM models.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
Polyfactory provides simple and powerful factories for mock data generation. Factories read the type hints of a model and generate valid values automatically, so UserFactory.build() returns a populated instance with little or no configuration.
It supports dataclasses, TypedDicts, Pydantic models, attrs classes, msgspec structs, Beanie and Odmantic documents and SQLAlchemy models. Fields can be overridden, use Faker, be generated with custom functions, or be marked to be ignored; batch builds and persistence handlers support databases. Pytest fixtures can be registered from factories.
Release v3.5.0 shipped in October 2026.
In the quality loop it supports Python unit and integration tests, especially for API models.
The source code is at litestar-org/polyfactory on GitHub under the MIT licence, with about 1,500 stars; the most recent commit was on 25 October 2026.
Features
- Type-hint driven: Automatic valid data.
- Many model types: Pydantic, dataclasses, attrs, msgspec and more.
- Overrides: Fixed or custom values.
- Batch builds: Many objects.
- Pytest fixtures: Register factories as fixtures.
Pros
- Minimal config: Types do the work.
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 25 October 2026.
Cons
- Random data: Set values that affect behaviour explicitly.
Usage and Links (Example)
from dataclasses import dataclass
from polyfactory.factories import DataclassFactory
@dataclass
class User:
name: str
age: int
class UserFactory(DataclassFactory[User]): ...
user = UserFactory.build()
Resources:
Pricing
Polyfactory is free and open source under the MIT licence.
Recommended for?
- Python teams using Pydantic or dataclasses.
- Not a fit for untyped code.
Conclusion
Polyfactory is a modern, type-driven factory library for Python.
On CheckOps, Polyfactory is filed under the Unit testing and Integration testing stages. Related tools listed here include factory_boy, Model Bakery, Faker (Python), Mimesis, Hypothesis and Fishery. Before choosing, compare them on licence, supported languages and platforms, hosting model, and how well each fits your existing CI pipeline. Facts on this page were checked against the official website, documentation and repository on 11 November 2026; statements the vendor makes about its own product are marked as vendor claims.
Compare
CheckOps pages that put Polyfactory next to related tools. There is no paid placement on these lists.
Roundups
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with Polyfactory side by side.
Ffactory_boyfactory_boy is an MIT-licensed test fixtures replacement for Python, inspired by thoughtbot's factory_bot, that builds test objects and ORM records for Django, SQLAlchemy and MongoEngine with Faker integration.Compare with Polyfactory
MModel BakeryModel Bakery is an Apache-2.0 library that creates Django model instances for tests with one line, filling required fields automatically, including related objects.Compare with Polyfactory
FFaker (Python)Faker is an MIT-licensed Python package that generates fake but realistic data such as names, addresses, text, dates and identifiers, with dozens of locales, a pytest fixture and seeding for reproducible test data.Compare with Polyfactory
MMimesisMimesis is an MIT-licensed Python library for generating fake but realistic data in 47 locales, with schema-based generation for JSON, XML and fixtures and a focus on speed.Compare with Polyfactory
HHypothesisHypothesis is the MPL-2.0 property-based testing library for Python: describe the range of inputs, let it generate cases including edge cases, and get the simplest failing example when a property breaks.Compare with Polyfactory
FFisheryFishery is an MIT-licensed TypeScript-first library from thoughtbot for defining factories that build JavaScript objects for tests, modelled on Ruby's factory_bot.Compare with Polyfactory