Skip to main content

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

Build Coverage Latest PyPI version Documentation Status

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-async is a fork of model-bakery that adds async-native fixture creation — baker.amake() / baker.aprepare() and their Baker counterparts — for use from async def tests 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.

The package imports as model_bakery_async (not model_bakery) so it can be installed alongside upstream model-bakery without colliding. All sync APIs from upstream are preserved.

Installation

pip install model-bakery-async

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_async 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

Sponsors

License

Model Bakery is licensed under Apache License 2.0. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_bakery_async-1.23.5.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

model_bakery_async-1.23.5-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file model_bakery_async-1.23.5.tar.gz.

File metadata

  • Download URL: model_bakery_async-1.23.5.tar.gz
  • Upload date:
  • Size: 30.9 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

Hashes for model_bakery_async-1.23.5.tar.gz
Algorithm Hash digest
SHA256 eed2e876b8a5aaf33c4784baa42891654780c3de03131e2995d689f952415e0c
MD5 554e52f69746013dd35137776ba99049
BLAKE2b-256 f3343df7965a6daefcc469869d87dde092ce7db83fd64765db06d4910d3fdf0c

See more details on using hashes here.

File details

Details for the file model_bakery_async-1.23.5-py3-none-any.whl.

File metadata

  • Download URL: model_bakery_async-1.23.5-py3-none-any.whl
  • Upload date:
  • Size: 33.5 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

Hashes for model_bakery_async-1.23.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2d10c01da1abe8b3bb545f41c58821cd91d33b7d813625c2d3f1262a063400f4
MD5 e43361091ee834f61bea2dfcf2ece9e5
BLAKE2b-256 f21d55565d40e0a7a197f0952cc9646e9102089ee664f1f1d2639ee74c464744

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page