https://github.com/miguelflg13/dataclass-bakery
Dataclass Bakery offers you a smart way to create objects based on dataclasses for testing in Python.
https://github.com/miguelflg13/dataclass-bakery
dataclasses python python3 testing testing-tools
Last synced: 10 months ago
JSON representation
Dataclass Bakery offers you a smart way to create objects based on dataclasses for testing in Python.
- Host: GitHub
- URL: https://github.com/miguelflg13/dataclass-bakery
- Owner: miguelFLG13
- License: apache-2.0
- Created: 2021-04-09T15:24:59.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-22T15:09:55.000Z (over 2 years ago)
- Last Synced: 2025-04-14T05:48:11.271Z (about 1 year ago)
- Topics: dataclasses, python, python3, testing, testing-tools
- Language: Python
- Homepage:
- Size: 57.6 KB
- Stars: 5
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
# Dataclass Bakery
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)