model-bakery 1.20.4
pip install model-bakery
Latest version
Released:
Smart object creation facility for Django.
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Apache Software License (Apache License 2.0)
- Author: berin
- Tags django, factory, python, testing
- Requires: Python >=3.8
-
Provides-Extra:
docs
,test
Classifiers
- Development Status
- Framework
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
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.
Model Bakery is a rename of the legacy Model Mommy project.
Install
pip install model-bakery
Usage and Info
Basic usage
# models.py
from django.db import models
class Customer(models.Model):
enjoy_jards_macale = models.BooleanField()
name = models.CharField(max_length=30)
email = models.EmailField()
age = models.IntegerField()
bio = models.TextField()
days_since_last_login = models.BigIntegerField()
birthday = models.DateField()
last_shopping = models.DateTimeField()
# test_models.py
from django.test import TestCase
from model_bakery import baker
from pprint import pprint
class TestCustomerModel(TestCase):
def setUp(self):
self.customer = baker.make('shop.Customer')
pprint(self.customer.__dict__)
"""
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
'age': 3841,
'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
'birthday': datetime.date(2019, 12, 3),
'enjoy_jards_macale': True,
'id': 1,
'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',
'days_since_last_login': 6016}
"""
Check out documentation for more complete examples.
Contributing
Detailed info here.
Maintainers
Creator
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Apache Software License (Apache License 2.0)
- Author: berin
- Tags django, factory, python, testing
- Requires: Python >=3.8
-
Provides-Extra:
docs
,test
Classifiers
- Development Status
- Framework
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
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
File details
Details for the file model_bakery-1.20.4.tar.gz
.
File metadata
- Download URL: model_bakery-1.20.4.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0c97e8a27329ecad78136f9d8f573ae392e4282326ea5c5f6daed1173013c4e |
|
MD5 | 4b12527ad618b4e04e28439b0ed4b892 |
|
BLAKE2b-256 | 05dc6d6260fa30c4d041958f71d6790b722e6f2588fbbca0534779b81a83b66d |
File details
Details for the file model_bakery-1.20.4-py3-none-any.whl
.
File metadata
- Download URL: model_bakery-1.20.4-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30ad372604f326a1ba9f949bad9d0f85e6a510db4ef6a0b07be2d6bd7485008b |
|
MD5 | 821021886447026c655ea197a8e377fc |
|
BLAKE2b-256 | 81239b30a9c70e1a6df5100ae8c440b98fc1da6a4ce195327a7fba399569a2ec |