Skip to main content

Dataclass Bakery offers you a smart way to create objects based on dataclasses for testing in Python

Project description

Dataclass Bakery offers you a smart way to create objects based on dataclasses for testing in Python. Inspired in model bakery module for Django.

Install

pip install dataclass_bakery

Usage and Info

Basic usage

from dataclasses import dataclass

from dataclass_bakery import baker


@dataclass
class Customer:
    id: int
    name: str
    spent_money: float


baker.make(Customer)
baker.make(Customer, _quantity=3)

"""
Customer(id=25, name='vzWoIfgoZM', spent_money=16.36)

[Customer(id=27, name='OYvyWakmUX', spent_money=84.98), Customer(id=41, name='AiancdsmLg', spent_money=57.57), Customer(id=92, name='feTxLyuSus', spent_money=26.06)]
"""

For more information: https://dataclass-bakery.readthedocs.io/

Types available:

  • int

  • str

  • float

  • bool

  • complex

  • date

  • datetime

  • range

  • list

  • tuple

  • dict

  • set

  • List (from typing import List)

  • Tuple (from typing import Tuple)

  • Dict (from typing import Dict)

  • Union (from typing import Union)

  • Optional (from typing import Optional)

  • Path (from pathlib import Path)

  • Decimal (from decimal import Decimal)

  • UUID (from uuid import UUID)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataclass-bakery-0.0.8.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dataclass_bakery-0.0.8-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file dataclass-bakery-0.0.8.tar.gz.

File metadata

  • Download URL: dataclass-bakery-0.0.8.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for dataclass-bakery-0.0.8.tar.gz
Algorithm Hash digest
SHA256 cdf09486780f0939993b725539d8701b65a84529dcccbd02a107ac9710ede0df
MD5 72ee0a0c885dd30d04e7e5c9ca9f2eff
BLAKE2b-256 f1e9ae7c36e6408ce9fe5a0ef0f330cee8c26af258f120d316fa0359a0ac8b43

See more details on using hashes here.

File details

Details for the file dataclass_bakery-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for dataclass_bakery-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fe529cb07ef8e0b8972f9c985ff267f7d5ca800f1e957b5256f3d1827fcd46a8
MD5 9c86d25c7c15f1b1c6d56292eb86a84f
BLAKE2b-256 05b4d5739c9dc99b57288f4326855110e36b0e14013a89e6fa19fbe01709bad6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page