Skip to main content

fauxgen

A factory method generator that streamlines test data creation by automating field value generation.

Overview

Testing classes with numerous fields often requires extensive boilerplate code. fauxgen addresses this challenge by automatically generating factory methods from class definitions, significantly reducing test code complexity.

Currently supports pandera.DataFrameModel with plans for future expansions.

Quick Start

uv add fauxgen
uv run fauxgen gen --module-dir <your_module>

Usage Example

Traditional Approach (Without fauxgen)

Testing DataFrame models traditionally requires explicit specification of all fields, even when testing a single validation:

import pandera as pa
from pandera.typing import Series

class UserSchema(pa.DataFrameModel):
    id: Series[int] = pa.Field(ge=1)
    age: Series[int] = pa.Field(ge=0, le=150)
    name: Series[str] = pa.Field()
    email: Series[str] = pa.Field(nullable=True)
    active: Series[bool] = pa.Field()

def test_user_registration():
    # Forced to specify every field when testing age validation
    df_user = pd.DataFrame([
        {
            "id": 1,            # Unrelated to test
            "age": 151,         # Actual test target
            "name": "test",     # Unrelated to test
            "email": "test@example.com",  # Unrelated to test
            "active": True,     # Unrelated to test
        },
    ]).pipe(DataFrame[UserSchema])
    # Test age validation...

Simplified Testing (With fauxgen)

fauxgen generates factory methods that enable focused testing by automatically handling irrelevant fields:

from .factories import user_schema_record  # Generated by fauxgen

def test_user_registration():
    # Focus solely on the field under test
    # Other fields are automatically populated with valid values
    df_user = pd.DataFrame([
        user_schema_record(age=151), # Set specific age for test
    ]).pipe(DataFrame[UserSchema])  # Test age validation...

def test_user_email_optional():
    # Effortlessly test specific scenarios
    # without worrying about irrelevant fields
    df_user = pd.DataFrame([
        user_schema_record(email=None)  # Set email to None for test
    ]).pipe(DataFrame[UserSchema])  # Test nullable email...

How It Works

Input: pandera.DataFrameModel Definition

import pandera as pa
from pandera.typing import Series

class TestSchema(pa.DataFrameModel):
    int_col: Series[int] = pa.Field(ge=0.1, le=10.0)
    float_col_only_ge: Series[float] = pa.Field(ge=10)
    float_col_only_le: Series[float] = pa.Field(le=10)
    pa_bool_col: Series[pa.Bool] = pa.Field(nullable=True)

Output: Generated Factory Method

import fauxgen as f

class TestSchemaRecord(TypedDict):
    int_col: int
    float_col_only_ge: float
    float_col_only_le: float
    pa_bool_col: bool | None

def test_schema_record(
    *,
    int_col: int | f.Unset = f.UNSET,
    float_col_only_ge: float | f.Unset = f.UNSET,
    float_col_only_le: float | f.Unset = f.UNSET,
    pa_bool_col: bool | None | f.Unset = f.UNSET,
    seed_: int | None = None,
) -> TestSchemaRecord:
    return {
        "int_col": f.Unset.unwrap_or_else(int_col, lambda: f.gen_int(ge=0.1, le=10, seed=seed_)),
        "float_col_only_ge": f.Unset.unwrap_or_else(float_col_only_ge, lambda: f.gen_float(ge=10, le=110, seed=seed_)),
        "float_col_only_le": f.Unset.unwrap_or_else(float_col_only_le, lambda: f.gen_float(ge=-90, le=10, seed=seed_)),
        "pa_bool_col": f.Unset.unwrap_or_else(pa_bool_col, lambda: f.gen_bool(seed=seed_)),
    }

Key Features

  1. Enhanced Type Safety:

    • Leverages TypedDict for comprehensive type checking
    • Provides full IDE support with type hints and autocompletion
  2. Intelligent Field Generation:

    • Selectively override specific fields while auto-generating others
    • Maintains data integrity through validation-aware value generation
  3. Validation-Aware Generation:

    • Automatically respects field constraints (ge, le, etc.)
    • Properly handles optional fields with nullable support

Metadata

Release files for fauxgen 0.1.0

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

Built distributions (wheels)

Table of built distributions (wheels) for fauxgen 0.1.0
File
fauxgen-0.1.0-py3-none-musllinux_1_1_x86_64.whl Python 3 none Linux musl 1.1+ x86-64 Details
fauxgen-0.1.0-py3-none-musllinux_1_1_armv7l.whl Python 3 none Linux musl 1.1+ ARMv7l Details
fauxgen-0.1.0-py3-none-musllinux_1_1_aarch64.whl Python 3 none Linux musl 1.1+ ARM64 Details
fauxgen-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
fauxgen-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl Python 3 none Linux glibc 2.17+ IBM System/390x Details
fauxgen-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl Python 3 none Linux glibc 2.17+ PowerPC 64-le Details
fauxgen-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl Python 3 none Linux glibc 2.17+ x86-32 Details
fauxgen-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details
fauxgen-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
fauxgen-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
fauxgen-0.1.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 22.9 MB

Release files / fauxgen-0.1.0-py3-none-musllinux_1_1_x86_64.whl

Download URL fauxgen-0.1.0-py3-none-musllinux_1_1_x86_64.whl
Size 2.2 MB
Tags Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f9f7ce02af03a8cb60a9059e4b8e4daacde6092759f62acc1d9a35efca57c5cb
BLAKE2b-256 checksum
How to use checksums
848e9f4293777ee964368624c90c25b0ace09fbfdef2d412a466bfcb7fa770cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-musllinux_1_1_armv7l.whl

Download URL fauxgen-0.1.0-py3-none-musllinux_1_1_armv7l.whl
Size 1.9 MB
Tags Linux musl 1.1+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
5230f9351c287b60245362fce9f0ae651ae83fe6b51b851306894bbfdf66544e
BLAKE2b-256 checksum
How to use checksums
d95dfe46ffdde5991d636abcfa9103534691d993b3be9f7915f7bf8ae9f18e91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-musllinux_1_1_aarch64.whl

Download URL fauxgen-0.1.0-py3-none-musllinux_1_1_aarch64.whl
Size 1.9 MB
Tags Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
e379c2eda8cb9469c25d307a0edb0877c282e049735ed77e8efd9f190f7373d5
BLAKE2b-256 checksum
How to use checksums
aabe5b6b25d632b14b44e86245746335be92f6ac0f19a4c3c1559b296d9ecbeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fauxgen-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.1 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
63a18a8fa3eff1bf1e97a8ad780da2c447a7b5887970dce41d598cf67fe0a4fa
BLAKE2b-256 checksum
How to use checksums
07d55d65cadfc7442a8dd638d920b9b141dc9bea36e97464c871c651068d410a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL fauxgen-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 2.4 MB
Tags Linux glibc 2.17+ IBM System/390x Python 3
SHA-256 checksum
How to use checksums
561f7eb93092da26117fc100c3eb922445a606224724562187e725a98ad01bda
BLAKE2b-256 checksum
How to use checksums
0aa5ba4cf395688c8000b9a2ac7b5b6e988ce1c748e94d29a5cfc38759bfb82b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL fauxgen-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 2.3 MB
Tags Linux glibc 2.17+ PowerPC 64-le Python 3
SHA-256 checksum
How to use checksums
878969e79e923fced83940a10e5e6ab227843e14ef73f66d4fb547e9e7af05c4
BLAKE2b-256 checksum
How to use checksums
0b2e7a570b491dd806283889dbdd5380ea1358ab66dae3f605568c2dc08d5fda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL fauxgen-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Size 2.2 MB
Tags Linux glibc 2.17+ x86-32 Python 3
SHA-256 checksum
How to use checksums
d38b5f972b8c8ed5265fb201cb8f708f1d28bc0255dafd3d1016468125a6be99
BLAKE2b-256 checksum
How to use checksums
06b18311cfa783b58c376d3f608395f4af1d15d5037801e96d1988b4c1c485f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL fauxgen-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 1.9 MB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
7d93411acc47349a387f1ac3796fa426ee1d84e153fa2bb0b35b061eee8dae99
BLAKE2b-256 checksum
How to use checksums
56d077a9dc1e136b4242a4d4a6adc22f0fda37043b2f4eb10eae121cd79e2360
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL fauxgen-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.0 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
c85468b149d42c571ec7a325a0d61fd1367c633b774ef1952ac22d601d2c9d12
BLAKE2b-256 checksum
How to use checksums
01e69bb82441ca2f515db4063e28b1ce1677690aa875bfc60afd3f0ee0633979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL fauxgen-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 1.9 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
478a15547a9214cd30502b76a231099334170b745dc8b3c2e8e172e4bf7ea7ec
BLAKE2b-256 checksum
How to use checksums
6d1293e800b023843168f15d2d922acdd0022f3828169cf1822b1a592de57bb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / fauxgen-0.1.0-py3-none-macosx_10_12_x86_64.whl

Download URL fauxgen-0.1.0-py3-none-macosx_10_12_x86_64.whl
Size 2.0 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5ff9122f4341ec34ebb094f7be3384cef0030ae489c24044b6a44d11a6e32d67
BLAKE2b-256 checksum
How to use checksums
daeafca16b46f1732cb817d696bab81c9b8e86229c1b76f798f3df07c7be06fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

0.3.1

11 release files

0.2.2

11 release files

0.2.0

11 release files

0.1.1

11 release files

This release

0.1.0 This release

11 release files

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