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/
Metadata
Release files for genuine 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| genuine-0.2.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| genuine-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.0 kB
Release files / genuine-0.2.0.tar.gz
| Download URL | genuine-0.2.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86f860ea1d2537717f7bcbdf5cf729362db992de8d071a682cec4ff62b546a7b
|
|
BLAKE2b-256 checksum How to use checksums |
4bdd1b10447c1c2351caea4f1a2994a206e46b26f7affd52b80856c5cadaeed3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.3 Darwin/22.6.0
|
Release files / genuine-0.2.0-py3-none-any.whl
| Download URL | genuine-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d639ba55ced4827efbc37c45caf04bae657405e08527a2247515b254e16db035
|
|
BLAKE2b-256 checksum How to use checksums |
fed8b200a63e9f27d3232a81f67310248874f6ecd559a2f63abf73968ca33c28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.3 Darwin/22.6.0
|