Mimesis Factory Save Abandoned

Mimesis integration with factory_boy

Project README

⛔️ DEPRECATED

This repository is now deprecated. We have integrated mimesis-factory into mimesis itself, and there is no longer a need to use a separate package. Refer to the Integration with factory_boy section for more details.

mimesis_factory

test codecov PyPI version wemake-python-styleguide

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.

Open Source Agenda is not affiliated with "Mimesis Factory" Project. README Source: lk-geimfari/mimesis-factory
Stars
52
Open Issues
4
Last Commit
2 months ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating