Async-enabled fork of model-bakery: smart object creation facility for Django, with baker.amake/aprepare.
Project description
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.
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
Creator
Sponsors
License
Model Bakery is licensed under Apache License 2.0. See the LICENSE file for more information.
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 model_bakery_async-1.23.6.tar.gz.
File metadata
- Download URL: model_bakery_async-1.23.6.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdd36f93fce1be0682ec49cef2b3fa7f2d79fbaa129817a1463dbfccd8533f85
|
|
| MD5 |
187fc0850fb81bdee20aa7c0e784d8db
|
|
| BLAKE2b-256 |
08772cdb5efe773a5f1d3fd80fcf7eee7d3e3c8ee3ec1909420d6f6dc2d047fc
|
File details
Details for the file model_bakery_async-1.23.6-py3-none-any.whl.
File metadata
- Download URL: model_bakery_async-1.23.6-py3-none-any.whl
- Upload date:
- Size: 33.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6bcc4410648c55eb0d16c12e3ed9794345010bb2d892a34eebb1b002a8594a6
|
|
| MD5 |
380996d8f97e34515bb44806dd0446c0
|
|
| BLAKE2b-256 |
2b36171f1ecd24bca93691d892f8af6ec99a90509365214c81a19cc1a22dfdea
|