All Projects → Goldziher → pydantic-factories

Goldziher / pydantic-factories

Licence: MIT license
Simple and powerful mock data generation using pydantic or dataclasses

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to pydantic-factories

ormsgpack
Msgpack serialization/deserialization library for Python, written in Rust using PyO3 and rust-msgpack. Reboot of orjson. msgpack.org[Python]
Stars: ✭ 88 (-76.84%)
Mutual labels:  dataclasses, pydantic
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-94.74%)
Mutual labels:  dataclasses, pydantic
json2python-models
Generate Python model classes (pydantic, attrs, dataclasses) based on JSON datasets with typing module support
Stars: ✭ 119 (-68.68%)
Mutual labels:  dataclasses, pydantic
erdantic
Entity relationship diagrams for Python data model classes like Pydantic
Stars: ✭ 63 (-83.42%)
Mutual labels:  dataclasses, pydantic
acord
An API wrapper for discord, built using aiohttp and pydantic.
Stars: ✭ 25 (-93.42%)
Mutual labels:  pydantic
aio-openapi
A python module for building OpenAPI compliant asynchronous Rest Servers. Auto documentation, serialization and validation in the same unified API.
Stars: ✭ 27 (-92.89%)
Mutual labels:  dataclasses
FactoryOrchestrator
A cross-platform system service which provides a simple way to run and manage factory line validation, developer inner-loop, diagnostics, and fault analysis workflows.
Stars: ✭ 36 (-90.53%)
Mutual labels:  factory
sitri
Sitri - powerful settings & configs for python
Stars: ✭ 20 (-94.74%)
Mutual labels:  pydantic
typeless
Typeless: the benefits of TypeScript, without the types
Stars: ✭ 17 (-95.53%)
Mutual labels:  tdd
ko-component-tester
🚦 TDD Helpers for Knockout JS
Stars: ✭ 15 (-96.05%)
Mutual labels:  tdd
mugshot
Framework independent visual testing library
Stars: ✭ 126 (-66.84%)
Mutual labels:  tdd
memo
다양한 MD 메모
Stars: ✭ 87 (-77.11%)
Mutual labels:  tdd
starlite
Light, Flexible and Extensible ASGI API framework
Stars: ✭ 1,525 (+301.32%)
Mutual labels:  pydantic
redis-om-python
Object mapping, and more, for Redis and Python
Stars: ✭ 590 (+55.26%)
Mutual labels:  pydantic
interface-forge
Graceful mock-data and fixtures generation using TypeScript
Stars: ✭ 58 (-84.74%)
Mutual labels:  factory
argparse dataclass
Declarative CLIs with argparse and dataclasses
Stars: ✭ 30 (-92.11%)
Mutual labels:  dataclasses
goss
Quick and Easy server testing/validation
Stars: ✭ 26 (-93.16%)
Mutual labels:  tdd
doctest
The fastest feature-rich C++11/14/17/20 single-header testing framework
Stars: ✭ 4,434 (+1066.84%)
Mutual labels:  tdd
pavlova
A python deserialisation library built on top of dataclasses
Stars: ✭ 32 (-91.58%)
Mutual labels:  dataclasses
Examin
Examin is a developer tool that generates React unit tests for your application. Ensure your application renders as expected before adding new features. Examin writes the baseline unit tests and allows developers to customize their tests for their application.
Stars: ✭ 75 (-80.26%)
Mutual labels:  tdd

Starlite logo

PyPI - License PyPI - Python Version

Language grade: Python Total alerts Coverage Maintainability Rating Reliability Rating Quality Gate Status

Discord

Pydantic-Factories

This library offers powerful mock data generation capabilities for pydantic based models, dataclasses and TypeDicts. It can also be used with other libraries that use pydantic as a foundation.

Check out the documentation 📚.

Installation

pip install pydantic-factories

Example

from datetime import date, datetime
from typing import List, Union

from pydantic import BaseModel, UUID4

from pydantic_factories import ModelFactory


class Person(BaseModel):
    id: UUID4
    name: str
    hobbies: List[str]
    age: Union[float, int]
    birthday: Union[datetime, date]


class PersonFactory(ModelFactory):
    __model__ = Person


result = PersonFactory.build()

That's it - with almost no work, we are able to create a mock data object fitting the Person class model definition.

This is possible because of the typing information available on the pydantic model and model-fields, which are used as a source of truth for data generation.

The factory parses the information stored in the pydantic model and generates a dictionary of kwargs that are passed to the Person class' init method.

Features

  • supports both built-in and pydantic types
  • supports pydantic field constraints
  • supports complex field types
  • supports custom model fields
  • supports dataclasses

Why This Library?

  • 💯 powerful
  • 💯 extensible
  • 💯 simple
  • 💯 rigorously tested

Contributing

This library is open to contributions - in fact we welcome it. Please see the contribution guide!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].