conformly
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)
| File | Size | Uploaded | |
|---|---|---|---|
| conformly-0.8.0.tar.gz | 48.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|