Skip to main content

factorio: A fixtures replacement tool

build lint tests license codecov readthedocs pypi downloads build automation: yam Lint: ruff

factorio is a fixtures replacement tool that's been heavily influenced by factory boy. It's intention is to hide irrelevant fields when writing a test.

Even though it's been designed to play well with various ORMs, it tries to avoid any interaction with a database, as the saving/retrieving an object shouldn't be the responsibility of the factory.

Under the hood it uses faker to create realistic values for each field.

Quick Start

from dataclasses import dataclass
from factorio import fields
from factorio.factories import Factory


@dataclass
class User:
    name: str
    email: str
    age: int


class UserFactory(Factory[User]):
    name = fields.TextField("name")
    email = fields.TextField("email")
    age = fields.IntegerField(min_value=18, max_value=65)


user = UserFactory.build()
# user.name might be "Sarah Johnson"
# user.email might be "sarah.johnson@example.com"
# user.age might be 34

Key Features

  • 🎯 Explicit Object Creation: Requires .build() method for clarity and safety
  • 🚫 No Database Interaction: Factories generate data, tests handle persistence
  • ✨ Realistic Data: Powered by Faker for lifelike test data
  • 🔧 20+ Field Types: From primitives to collections and nested factories
  • 🎨 Flexible Overrides: Override fields with values or dynamic field instances
  • 📦 ORM Agnostic: Works with dataclasses, Pydantic, SQLAlchemy, and more
  • 🛡️ Type Safe: Full type hints and mypy support

Documentation

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

factorio-0.8.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

factorio-0.8.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file factorio-0.8.0.tar.gz.

File metadata

  • Download URL: factorio-0.8.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for factorio-0.8.0.tar.gz
Algorithm Hash digest
SHA256 7fefee87ce6988500089e22be2c40bcc20966d32bf26b8659573b313c682b80a
MD5 7bd70f270c87c428a506306d86a1e066
BLAKE2b-256 78adb2bfe235c82fff6803cf5a30448c0935009b9d866bdd31f6f049ef9ffe69

See more details on using hashes here.

File details

Details for the file factorio-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: factorio-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for factorio-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3905451371112f4ebce2db49b5a882b473c5e12d8c2f0384c14f51d13e93d5b4
MD5 320c164d48b69af6ed43140cdb5c2b32
BLAKE2b-256 6e6bf3b03a0da5edf25e03eddb9158c0ab8dc439875c0f862f58e333ab95837a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page