{"id":27935681,"url":"https://github.com/hiro-o918/fauxgen","last_synced_at":"2025-07-20T22:34:12.939Z","repository":{"id":284155953,"uuid":"953995112","full_name":"hiro-o918/fauxgen","owner":"hiro-o918","description":"A factory method generator that streamlines test data creation by automating field value generation.","archived":false,"fork":false,"pushed_at":"2025-07-10T05:51:49.000Z","size":203,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-10T14:31:30.426Z","etag":null,"topics":["python","testing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/fauxgen/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiro-o918.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-24T12:03:36.000Z","updated_at":"2025-07-10T05:51:38.000Z","dependencies_parsed_at":"2025-04-19T03:40:18.186Z","dependency_job_id":"01c24cff-8761-405e-a71e-288ad59b84f3","html_url":"https://github.com/hiro-o918/fauxgen","commit_stats":null,"previous_names":["hiro-o918/fakerator","hiro-o918/pyfakerator"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/hiro-o918/fauxgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiro-o918%2Ffauxgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiro-o918%2Ffauxgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiro-o918%2Ffauxgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiro-o918%2Ffauxgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiro-o918","download_url":"https://codeload.github.com/hiro-o918/fauxgen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiro-o918%2Ffauxgen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266210843,"owners_count":23893338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","testing"],"created_at":"2025-05-07T06:50:17.523Z","updated_at":"2025-07-20T22:34:12.916Z","avatar_url":"https://github.com/hiro-o918.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fauxgen\n\nA factory method generator that streamlines test data creation by automating field value generation.\n\n## Overview\n\nTesting 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.\n\nCurrently supports `pandera.DataFrameModel` with plans for future expansions.\n\n## Quick Start\n\n```bash\nuv add fauxgen\nuv run fauxgen gen --module-dir \u003cyour_module\u003e\n```\n\n## Usage Example\n\nExample project can be found in the [examples](./examples/).\n\n### Traditional Approach (Without fauxgen)\n\nTesting DataFrame models traditionally requires explicit specification of all fields, even when testing a single validation:\n\n```python\nimport pandera as pa\nfrom pandera.typing import Series\n\nclass UserSchema(pa.DataFrameModel):\n    id: Series[int] = pa.Field(ge=1)\n    age: Series[int] = pa.Field(ge=0, le=150)\n    name: Series[str] = pa.Field()\n    email: Series[str] = pa.Field(nullable=True)\n    active: Series[bool] = pa.Field()\n\ndef test_user_registration():\n    # Forced to specify every field when testing age validation\n    df_user = pd.DataFrame([\n        {\n            \"id\": 1,            # Unrelated to test\n            \"age\": 151,         # Actual test target\n            \"name\": \"test\",     # Unrelated to test\n            \"email\": \"test@example.com\",  # Unrelated to test\n            \"active\": True,     # Unrelated to test\n        },\n    ]).pipe(DataFrame[UserSchema])\n    # Test age validation...\n```\n\n### Simplified Testing (With fauxgen)\n\nfauxgen generates factory methods that enable focused testing by automatically handling irrelevant fields:\n\n```python\nfrom .factories import user_schema_record  # Generated by fauxgen\n\ndef test_user_registration():\n    # Focus solely on the field under test\n    # Other fields are automatically populated with valid values\n    df_user = pd.DataFrame([\n        user_schema_record(age=151), # Set specific age for test\n    ]).pipe(DataFrame[UserSchema])  # Test age validation...\n\ndef test_user_email_optional():\n    # Effortlessly test specific scenarios\n    # without worrying about irrelevant fields\n    df_user = pd.DataFrame([\n        user_schema_record(email=None)  # Set email to None for test\n    ]).pipe(DataFrame[UserSchema])  # Test nullable email...\n```\n\n## How It Works\n\n### Input: pandera.DataFrameModel Definition\n\n```python\nimport pandera as pa\nfrom pandera.typing import Series\n\nclass TestSchema(pa.DataFrameModel):\n    int_col: Series[int] = pa.Field(ge=0.1, le=10.0)\n    float_col_only_ge: Series[float] = pa.Field(ge=10)\n    float_col_only_le: Series[float] = pa.Field(le=10)\n    pa_bool_col: Series[pa.Bool] = pa.Field(nullable=True)\n```\n\n### Output: Generated Factory Method\n\n```python\nimport fauxgen as f\n\nclass TestSchemaRecord(TypedDict):\n    int_col: int\n    float_col_only_ge: float\n    float_col_only_le: float\n    pa_bool_col: bool | None\n\ndef test_schema_record(\n    *,\n    int_col: int | f.Unset = f.UNSET,\n    float_col_only_ge: float | f.Unset = f.UNSET,\n    float_col_only_le: float | f.Unset = f.UNSET,\n    pa_bool_col: bool | None | f.Unset = f.UNSET,\n    seed_: int | None = None,\n) -\u003e TestSchemaRecord:\n    return {\n        \"int_col\": f.Unset.unwrap_or_else(int_col, lambda: f.gen_int(ge=0.1, le=10, seed=seed_)),\n        \"float_col_only_ge\": f.Unset.unwrap_or_else(float_col_only_ge, lambda: f.gen_float(ge=10, le=110, seed=seed_)),\n        \"float_col_only_le\": f.Unset.unwrap_or_else(float_col_only_le, lambda: f.gen_float(ge=-90, le=10, seed=seed_)),\n        \"pa_bool_col\": f.Unset.unwrap_or_else(pa_bool_col, lambda: f.gen_bool(seed=seed_)),\n    }\n```\n\n### Key Features\n\n1. **Enhanced Type Safety**:\n\n   - Leverages TypedDict for comprehensive type checking\n   - Provides full IDE support with type hints and autocompletion\n\n2. **Intelligent Field Generation**:\n\n   - Selectively override specific fields while auto-generating others\n   - Maintains data integrity through validation-aware value generation\n\n3. **Validation-Aware Generation**:\n   - Automatically respects field constraints (`ge`, `le`, etc.)\n   - Properly handles optional fields with `nullable` support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiro-o918%2Ffauxgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiro-o918%2Ffauxgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiro-o918%2Ffauxgen/lists"}