Giter VIP home page Giter VIP logo

dataclass-bakery's Introduction

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
  • 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)

dataclass-bakery's People

Contributors

miguelflg13 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.