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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f860ea1d2537717f7bcbdf5cf729362db992de8d071a682cec4ff62b546a7b
|
|
| MD5 |
d354e243b9d745dc58a6758d24710f8b
|
|
| BLAKE2b-256 |
4bdd1b10447c1c2351caea4f1a2994a206e46b26f7affd52b80856c5cadaeed3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d639ba55ced4827efbc37c45caf04bae657405e08527a2247515b254e16db035
|
|
| MD5 |
4db6b199d98de3cf1f9746d080ccdd9b
|
|
| BLAKE2b-256 |
fed8b200a63e9f27d3232a81f67310248874f6ecd559a2f63abf73968ca33c28
|