Skip to main content

conformly

CI codecov PyPI Python Versions

License: MIT Status: Beta Checked with mypy Ruff

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, strategy=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.8.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.8.0
File Size Uploaded
conformly-0.8.0.tar.gz 48.6 kB Details

Built distribution (wheel)

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

Total release size: 125.7 kB

Release files / conformly-0.8.0.tar.gz

Download URL conformly-0.8.0.tar.gz
Size 48.6 kB
Tags Source
SHA-256 checksum
How to use checksums
587ec7e21fdfc6b91428b7f76a49bd6cc0aeace2eac7a5ab5fc75583757698b4
BLAKE2b-256 checksum
How to use checksums
fab8fc779fcdd42cc82503a5377260f9b8de90a44b52116c3bcf1ba95612f1fa
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.8.0-py3-none-any.whl

Download URL conformly-0.8.0-py3-none-any.whl
Size 77.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e59feb2ce7a687f3c1d0f6023f25ca362e0757aab7e236a9d51002ad0f7cef6
BLAKE2b-256 checksum
How to use checksums
8c4c7f80501a274a8cb8958a0f0907a9da305076418c1556419e1b925943bb41
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

0.9.0

2 release files

This release

0.8.0 This release

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