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

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file genuine-0.2.0.tar.gz.

File metadata

  • Download URL: genuine-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.3 Darwin/22.6.0

File hashes

Hashes for genuine-0.2.0.tar.gz
Algorithm Hash digest
SHA256 86f860ea1d2537717f7bcbdf5cf729362db992de8d071a682cec4ff62b546a7b
MD5 d354e243b9d745dc58a6758d24710f8b
BLAKE2b-256 4bdd1b10447c1c2351caea4f1a2994a206e46b26f7affd52b80856c5cadaeed3

See more details on using hashes here.

File details

Details for the file genuine-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: genuine-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.3 Darwin/22.6.0

File hashes

Hashes for genuine-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d639ba55ced4827efbc37c45caf04bae657405e08527a2247515b254e16db035
MD5 4db6b199d98de3cf1f9746d080ccdd9b
BLAKE2b-256 fed8b200a63e9f27d3232a81f67310248874f6ecd559a2f63abf73968ca33c28

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