Mock data generation for pydantic based models
Project description
Pydantic Factories
This library offers mock data generation for pydantic based models. This means any user defined models as well as third party libraries that use pydantic as a foundation, e.g. SQLModel, FastAPI, Beanie, Ormar and others.
Features
- ✅ supports both built-in and pydantic types
- ✅ supports pydantic field constraints
- ✅ supports complex field typings
- ✅ supports custom model fields
Why This Library?
- 💯 powerful mock data generation
- 💯 simple to use and extend
- 💯 rigorously tested
Installation
pip install pydantic-factories
OR
poetry add --dev pydantic-factories
Usage
from datetime import date, datetime
from typing import List, Union
from pydantic import BaseModel, UUID4
from pydantic_factories.factory import ModelFactory
class Person(BaseModel):
id: UUID4
name: str
hobbies: List[str]
age: Union[float, int]
birthday: Union[datetime, date]
class PersonFactoryWithDefaults(ModelFactory):
__model__ = Person
result = PersonFactoryWithDefaults.build()
That's it - the factory will create a data object that fits the defined model and pass it to the pydantic model as kwargs. It will then pass through the pydantic validation and parsing mechanism, and create a model instance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pydantic-factories-0.3.0b0.tar.gz
.
File metadata
- Download URL: pydantic-factories-0.3.0b0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.8 Linux/5.11.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c4e0ae9035c05f21af6b4d1a658a9dd81d9b930daaed19a181f2d905dcd43e |
|
MD5 | 3fdb8441d3aceb60a6fb97b41b41aa0a |
|
BLAKE2b-256 | b12f6ae1896207fa00f21832e0c50d756ca4041dbb60cd4ff72c9ddca32eef2d |
File details
Details for the file pydantic_factories-0.3.0b0-py3-none-any.whl
.
File metadata
- Download URL: pydantic_factories-0.3.0b0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.8 Linux/5.11.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9efa532fd99835a4d29d4014f5b62ff6ade25eec67b21e7c31c9c9fa3a3f373b |
|
MD5 | 2ed7c48ea8e5948e6752a76d85f636dc |
|
BLAKE2b-256 | a4419ed9b4c177bdfe187ce38b5488aac0bf8d7b1d92a61fde031e6981f385be |