peewee_model_factory
No time? Ready to use?
pip install peewee-model-factory
from peewee_model_factory import model_factory
from model import Author, Book
author = model_factory(Author, fill_nullable_values=True)
book = model_factory(Book, author=author)
Need custom type generation?
import peewee as pw
from peewee_model_factory import model_factory
def char_field_factory(field: pw.Field) -> str:
return f"my char value for field: {field.name}"
field_type_map = {
pw.CharField: char_field_factory,
}
def my_custom_model_factory(*args, **kwargs) -> pw.Model:
return model_factory(*args, custom_field_type_map=field_type_map, **kwargs)
Want to use with peewee-async?
import peewee as pw
from peewee_model_factory import model_factory
from peewee_async import Manager
manager = Manager(...)
def my_custom_model_factory(*args, **kwargs) -> pw.Model:
with manager.allow_sync():
return model_factory(*args, **kwargs)
Description
A library to create peewee model instances for testing. The project creation has been inspired by django-dynamic-fixture and peewee-fake_fixtures projects.
Features
- Recursevely creating models for foreign fields
- An option for filling nullable values
- Easy customization if you need to extend or change generation for types of peewee fields
Possible inconvenience
- The project has no tests.
- Not all field types of peeweee has factory function in the project. You have to write custom one if you want to use them
Metadata
Release files for peewee-model-factory 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| peewee-model-factory-0.1.1.tar.gz | 4.1 kB | Without provenance | Details for peewee-model-factory-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| peewee_model_factory-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for peewee_model_factory-0.1.1-py3-none-any.whl |
Total release size: 10.1 kB
Release files / peewee-model-factory-0.1.1.tar.gz
| Download URL | peewee-model-factory-0.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e651d94f3f95ce07674e2db3794d0328eb4fe55aa7f1fcba6048bfaf8ca466e6
|
|
BLAKE2b-256 checksum How to use checksums |
0444b5943cd045069e95dc5d67c9e77d83c7cc3d34bc01fab9e86028f82e977e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
|
Release files / peewee_model_factory-0.1.1-py3-none-any.whl
| Download URL | peewee_model_factory-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af9947e44a1c6679484b8e9a83d7ebee824b4bbfda6494ca9a18d7d5b17f32c0
|
|
BLAKE2b-256 checksum How to use checksums |
7deadd8bc6e9e9b4cf04bda3edb2a9beae320ba9d31f294eb1219c0b99f364b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
|
Security for peewee-model-factory 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.