autofaker
Python library designed to minimize the setup/arrange phase of your unit tests
What it is and what it does
AutoFaker is a test data generation library that automates the arrange phase of unit tests by creating anonymous instances of types on demand. Instead of manually instantiating objects with placeholder values just to satisfy type requirements, you call Autodata.create(SomeType) and get a populated instance. It supports built-in types (int, str, float, datetime), dataclasses, nested classes, enums, Literal types, and pandas DataFrames. When you need realistic rather than random data, you can enable fake data generation via faker to populate fields with names, addresses, emails, and other plausible values.
The library provides two main interfaces: direct calls like Autodata.create(int) for one-off generation, and decorators (@autodata, @fakedata) that inject generated arguments into test methods, letting you declare what types you need as function parameters or type annotations. It's designed for ETL and data-heavy testing scenarios but works for any test that needs to reduce setup boilerplate.
Use it for:
- Reduce arrange-phase code in unit tests by auto-generating simple types and dataclass instances instead of manual instantiation.
- Generate realistic fake data (names, addresses, emails) for integration tests of data pipelines and ETL workflows.
- Populate nested object graphs and collections automatically without writing recursive factory code.
- Parameterize test methods with generated arguments using @autodata decorator to keep test code concise.
- Create anonymous pandas DataFrames with random or fake data for testing data transformation logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
AutoFaker generates anonymous test data and objects automatically, reducing boilerplate in unit test setup by creating instances of built-in types, dataclasses, and custom classes with minimal configuration.
Yes. Low install friction, active maintenance, no known vulnerabilities, permissive license, and a clear fit for test-heavy projects. Install if you write unit tests and want to reduce setup boilerplate; skip only if your test suite is minimal or you prefer explicit test data factories.
Install
autofaker on PyPI
pip
pip install autofakeruv
uv add autofakerpoetry
poetry add autofakerInstalling autofaker
Before you install
Low friction: pure Python wheel with only three runtime dependencies (pandas, faker, typing_inspect). Actively maintained with recent releases; last commit 2026-07-30. Requires Python 3.10 or newer.
License in practice
MIT license (permissive) allows use in commercial and private projects with minimal restrictions; attribution required but no copyleft obligations.
Quickstart
pip install autofaker
from autofaker import Autodata
from dataclasses import dataclass
@dataclass
class User:
id: int
name: str
user = Autodata.create(User)
print(user.id, user.name)
# With fake data
user_fake = Autodata.create(User, use_fake_data=True)
print(user_fake.name) # e.g., 'Justin Wise'
Requires Python 3.10 or newer.
Verify before relying
- Whether the library handles all common test scenarios or has known gaps in type coverage beyond what the description lists.
- Performance characteristics when generating large test datasets or deeply nested object graphs.
- Integration maturity with popular test frameworks beyond unittest (pytest, nose2, etc.).
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — pandas, faker, typing_inspect |
| Maintenance | actively maintained — 70 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 208,464/month — #9,531 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: autofaker-2.0.24-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
streamlit-fakerGenerates random fake data to populate…
unclear · top 15,000 on PyPI
robotframework-fakerWraps Faker's random test data generation as…
permissive · top 15,000 on PyPI
faker-e164Generates fake E164-formatted phone numbers for…
permissive · top 15,000 on PyPI
faker-enumAdds enum value generation to the Faker…
permissive · top 15,000 on PyPI
odoo-test-helperProvides utilities for writing Odoo tests,…
copyleft · top 15,000 on PyPI
FakerFaker generates realistic fake data—names,…
permissive · top 1,000 on PyPI
fake-factoryfake-factory is a deprecated package that…
permissive · top 15,000 on PyPI
pytest-fakerProvides pytest fixtures that integrate the…
permissive · top 15,000 on PyPI
polyfactoryPolyfactory generates mock data objects from…
permissive · top 5,000 on PyPI
aiounittestProvides a test case class for writing unit…
permissive · top 15,000 on PyPI