Skip to main content

Genuine makes it easy to create test data and associations.

Project description

Genuine

Genuine makes it easy to create test data and associations. It is inspired by ruby factory-bot.

It has a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, and attribute mappings), and support for multiple factories for the same class.

Installation

pip install genuine

Usage

from genuine import build
from dataclasses import dataclass

@dataclass
class User:
    name: str
    age: int
    admin: bool = False

instance = build(User)
assert isinstance(instance, User)

With a factory

from genuine import define_factory

with define_factory(User) as factory:
    factory.set("name", "John")

instance = build(User)
assert instance.name == "John"

Nested model objects

@dataclass
class Comment:
    body: str
    commenter: User


with define_factory(Comment) as factory:
    factory.set("body", "awesome")
    factory.association("commenter", User)

assert build(Comment).commenter.name == "John"

Doc

more example are located here https://johnnoone.github.io/genuine/

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

genuine-0.2.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

genuine-0.2.0-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

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