Skip to main content

factory_bot

Test data factories with the ergonomics of Ruby's factory_bot.

Early development: the API is still settling.

Install

pip install factory_bot

Usage

from factory_bot import build, factory, fake, sequence

@factory(User)
def user(f):
    f.first_name = fake.first_name                    # callables run per build
    f.email = lambda first_name: f"{first_name}@example.com".lower()  # dependencies by name
    f.username = sequence(lambda n: f"user{n}")
    f.admin = False

    @f.trait
    def admin(f):
        f.admin = True

build("user")
# User(first_name='Dennis', email='dennis@example.com', username='user1', admin=False)

build("user", "admin", first_name="Jane")
# User(first_name='Jane', email='jane@example.com', username='user2', admin=True)

installs

Metadata

Release files for factory-bot 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for factory-bot 0.0.1
File Size Uploaded Provenance Actions
factory_bot-0.0.1.tar.gz 7.4 kB Without provenance Details for factory_bot-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for factory-bot 0.0.1
File Interpreter ABI Platform Actions
factory_bot-0.0.1-py3-none-any.whl Python 3 none any Details for factory_bot-0.0.1-py3-none-any.whl

Total release size: 13.0 kB

Release files / factory_bot-0.0.1.tar.gz

Download URL factory_bot-0.0.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1ded373ebf8f85661da88fe2eadc12ce2d30541d48bb425c3a3c34cad60c705c
BLAKE2b-256 checksum
How to use checksums
7c3bb7fbd0634a5e6729554f441629f89405ed1146471c410b2c840647bf3125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / factory_bot-0.0.1-py3-none-any.whl

Download URL factory_bot-0.0.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcdf75dbb12a677cda7344083470d1a882939adbcc83f985c5e8a946069fbb2a
BLAKE2b-256 checksum
How to use checksums
d21404d377afc77c2a14f9aeaa54954acd0d38e48a6903b2e4e2724642daa997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for factory-bot 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page