Skip to main content

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.

Metadata

Release files for conformly 0.9.0

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

Source distribution (sdist)

Source distribution for conformly 0.9.0
File Size Uploaded
conformly-0.9.0.tar.gz 48.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conformly 0.9.0
File Interpreter ABI Platform
conformly-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 126.0 kB

Release files / conformly-0.9.0.tar.gz

Download URL conformly-0.9.0.tar.gz
Size 48.7 kB
Tags Source
SHA-256 checksum
How to use checksums
558b9b7348902500ccbe233f91db594650998070f8fef07a15afc3cefb49a2e5
BLAKE2b-256 checksum
How to use checksums
4ca18a2b20d1b79a2243b62b60c42dde5c48c80b8169007058ad904a519e9d57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / conformly-0.9.0-py3-none-any.whl

Download URL conformly-0.9.0-py3-none-any.whl
Size 77.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69d74741e561e93d08889ed159b3a8228fd1787fb8088ec7c093d135263a1566
BLAKE2b-256 checksum
How to use checksums
a7979547990b0b220ab88f245cba18809bd7de878e762d4e8b4faa59402bd0ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 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