Extensions for Factory Boy
Project description
Factory-Man
Factory-Man provides extensions for Factory Boy.
Features
ModelFieldSequence
extends factory.Sequence
to provide a little more DRY syntax. It takes in a string
parameter and uses it to create a unique value for each object by adding -n
to the string, where n
is the count of objects created.
When working with Django, ModelFieldSequence
can also accept a model
parameter instead of string
. The model
should be a Django model. The name of the model and the field to which ModelFieldSequence
is signed to are used to automatically create the string
. model
can also be used as a positional argument.
Example:
from factory.django import DjangoModelFactory as ModelFactory
from factoryman import ModelFieldSequence
class CharityFactory(ModelFactory):
class Meta:
model = Charity
name = ModelFieldSequence(Charity) # Will be `Charity__name-n`, where n is the object count
email = ModelFieldSequence(string='hello@charity.ee') # Will be `hello@charity.ee-n`, where n is the object count
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
factory-man-0.1.0.tar.gz
(2.0 kB
view hashes)
Built Distribution
Close
Hashes for factory_man-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89148c73ad99de36c93a31f199f3810d82c94e99749564bcd482facbd56f1541 |
|
MD5 | f0975814a0d59af10b7c8f0db39b7d15 |
|
BLAKE2b-256 | 7063efbe538dd419dac424e387e1c2804bb691ef8619a1315e20ab8e8b8304e2 |