Mimesis integration with factory_boy
Project description
mimesis_factory
Description
Mimesis integration for factory_boy
.
Installation
➜ pip install mimesis_factory
Usage
Look at the example below and you’ll understand how it works:
class Account(object):
def __init__(self, username, email, name, surname, age):
self.username = username
self.email = email
self.name = name
self.surname = surname
self.age = age
Now, use the MimesisField
class from mimesis_factory
to define how fake data is generated:
import factory
from mimesis_factory import MimesisField
from account import Account
class AccountFactory(factory.Factory):
class Meta(object):
model = Account
username = MimesisField('username', template='l_d')
name = MimesisField('name', gender='female')
surname = MimesisField('surname', gender='female')
age = MimesisField('age', minimum=18, maximum=90)
email = factory.LazyAttribute(
lambda instance: '{0}@example.org'.format(instance.username)
)
access_token = MimesisField('token', entropy=32)
pytest
We also recommend to use pytest-factoryboy
.
This way it will be possible to integrate your factories into pytest
fixtures.
License
mimesis_factory
is released under the MIT License.
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
mimesis_factory-1.2.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for mimesis_factory-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2905f2e90f0e7038877a1878e017bc6882ff46b4036e075e03677a63f16bb4cd |
|
MD5 | 852919876c854cfc0fda5e82b1bcda6e |
|
BLAKE2b-256 | c2b2120d930d60529f32402f617936f4bc3a4011125aa30abd208bab99bd89c2 |