Mimesis integration with factory_boy.
Switch branches/tags
Clone or download
Latest commit 3f650d3 Nov 27, 2018



Build Status Coverage Python PyPI version


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
        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:
        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 o: '%s@example.org' % o.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.