skillfed

autofaker

Python library designed to minimize the setup/arrange phase of your unit tests

autofaker v2.0.24 208.5K downloads/30d#9,531 on PyPI8
Permissive license Active released

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 autofaker

uv

uv add autofaker

poetry

poetry add autofaker

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

unit test data generationtest fixture automationanonymous object creationarrange phase simplificationfake data for testingtest setup boilerplate reductionautofixture python
test-data-generationunit-testingtest-fixtures

More Testing packages