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.1

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.1
File Size Uploaded Provenance Actions
conformly-0.9.1.tar.gz 48.7 kB Without provenance Details for conformly-0.9.1.tar.gz

Built distribution (wheel)

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

Total release size: 126.1 kB

Release files / conformly-0.9.1.tar.gz

Download URL conformly-0.9.1.tar.gz
Size 48.7 kB
Tags Source
SHA-256 checksum
How to use checksums
077ea9f27a1def501f5743889113672def1b612565d19524050e47a044ba3bd6
BLAKE2b-256 checksum
How to use checksums
1a747e13e614a69a09e545845dc135306cdcd6f758c42ed297071743f96d1727
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.1-py3-none-any.whl

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

Security for conformly 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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