Skip to main content

Mimesis integration with factory_boy

Project description


Build Status Coverage PyPI version wemake-python-styleguide


Mimesis integration for factory_boy.


  pip install mimesis_factory


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 = email = 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}'.format(instance.username)
    access_token = MimesisField('token', entropy=32)


We also recommend to use pytest-factoryboy. This way it will be possible to integrate your factories into pytest fixtures.


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.

Files for mimesis-factory, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size mimesis_factory-1.2.0-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mimesis_factory-1.2.0.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page