Model Bakery: Smart fixtures for better tests
Model Bakery offers you a smart way to create fixtures for testing in Django. With a simple and powerful API, you can create many objects with a single line of code.
About this fork
model-bakery-asyncis a fork of model-bakery that adds async-native fixture creation —baker.amake()/baker.aprepare()and theirBakercounterparts — for use fromasync deftests on Django's async ORM.It packages the work from upstream PR #599, which the upstream maintainers declined to merge citing the maintenance burden of a parallel async implementation (the code quality was not in question). We maintain it here so projects that need async fixtures can depend on a published package.
It is a drop-in replacement: the distribution is
model-bakery-asyncbut it imports asmodel_bakery, and all sync APIs from upstream are preserved. Because it shares themodel_bakeryimport namespace, install either this package or upstreammodel-bakery— not both.Versions are the upstream release they are based on plus a fourth fork-revision number:
1.24.1.1is upstream 1.24.1 with fork revision 1.
Installation
pip install model-bakery-async
Then import it exactly like upstream model-bakery:
from model_bakery import baker
Supported Versions
Model Bakery follows the Python and Django release and support cycles. We drop support for Python and Django versions when they reach end-of-life.
Basic usage
# models.py
from django.db import models
class Customer(models.Model):
name = models.CharField(max_length=30)
email = models.EmailField()
age = models.IntegerField()
is_jards_macale_fan = models.BooleanField()
bio = models.TextField()
birthday = models.DateField()
last_shopping = models.DateTimeField()
# test_models.py
from django.test import TestCase
from model_bakery import baker
class TestCustomerModel(TestCase):
def setUp(self):
self.customer = baker.make('shop.Customer')
print(self.customer.__dict__)
"""
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
'age': 3841,
'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
'birthday': datetime.date(2019, 12, 3),
'email': 'rpNATNsxoj@example.com',
'is_jards_macale_fan': True,
'id': 1,
'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'}
"""
Documentation
For more detailed information, check out the full documentation.
Contributing
As an open-source project, Model Bakery welcomes contributions of many forms:
- Code patches
- Documentation improvements
- Bug reports
Take a look at our contribution guidelines for instructions on how to set up your local environment.
Maintainers
Contributors
Model Bakery is built by its community. See the full list of contributors.
Project history
Model Bakery was originally created by Vanderson Mota as Model Mommy. The project was previously maintained in the berinhard/model_mommy repository before being renamed and moved here.
Sponsors
License
Model Bakery is licensed under Apache License 2.0. See the LICENSE file for more information.
Metadata
Release files for model-bakery-async 1.24.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 | |
|---|---|---|---|
| model_bakery_async-1.24.1.1.tar.gz | 32.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| model_bakery_async-1.24.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 67.7 kB
Release files / model_bakery_async-1.24.1.1.tar.gz
| Download URL | model_bakery_async-1.24.1.1.tar.gz |
|---|---|
| Size | 32.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef4c9e9840e1646a335e2702afa14933a1a1ce9563902464e2bd662c55b605e5
|
|
BLAKE2b-256 checksum How to use checksums |
b0f7f38bbd0b019b1187690e902fd612a89581f884fda01c386be814f44d1c40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / model_bakery_async-1.24.1.1-py3-none-any.whl
| Download URL | model_bakery_async-1.24.1.1-py3-none-any.whl |
|---|---|
| Size | 35.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee43e2084171f9c430e0335b1b9054b75cf8eb59e1ed26319280b1535d27db4c
|
|
BLAKE2b-256 checksum How to use checksums |
c63c9e4e0bc3b74400b5bc16604247fe70155e259a7c101ba8a701fd21fbb4f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|