Skip to content
nashabanovPublic

About

Generate valid & invalid test data from your typed schemas

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

conformly

CI codecov PyPI Python Versions License: MIT

Declarative test data generator for Python.

Define constraints once in type annotations — generate both valid and minimal invalid test data automatically. No factories, no hardcoded fixtures, no drift when schema changes.

Conformly turns typed schemas into dictionaries for fixtures and validation tests. Use the same schema for happy-path payloads and targeted negative cases.

Key capabilities

  • Constraint-driven generation from type annotations and model metadata.
  • Minimal invalid cases targeting one field and a selected violation.
  • Schema as the single source of truth for test data.
  • Dataclasses and TypedDicts, with optional Pydantic and attrs integrations.
  • Nested models, collections, reproducible seeds, and field overrides.

Installation

Requires Python 3.12 or newer.

pip install conformly
# Optional integrations:
pip install 'conformly[pydantic]'
pip install 'conformly[attrs]'

Quickstart

from dataclasses import dataclass
from typing import Annotated

from conformly import GreaterOrEqual, MaxLength, MinLength, V, case, path


@dataclass
class CreateUser:
    username: Annotated[str, MinLength(3), MaxLength(32)]
    age: Annotated[int, GreaterOrEqual(18)]


payload = case(CreateUser)
assert 3 <= len(payload["username"]) <= 32
assert payload["age"] >= 18

invalid = case(
    CreateUser, valid=False, target=path("age").violate(V.BELOW_MIN)
)
assert invalid["age"] < 18
assert 3 <= len(invalid["username"]) <= 32

Results are dictionaries, not model instances. Invalid generation targets one field; only the selected violation is guaranteed on that target. Defaults and overrides are trusted rather than validated. See the invalid generation contract.

Documentation and examples

Start with Getting started, browse the documentation index, or run the examples. The API reference lists parameters and defaults.

Development and contributing

See CONTRIBUTING.md for setup and checks, and CHANGELOG.md for release notes and migration guidance.

License

MIT — see LICENSE.

About

Generate valid & invalid test data from your typed schemas

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages