Use to solve circular dependencies issues.
Variant of LazyAttribute, also receives the containers of the object.
Evaluate the current ContainerAttribute.
Same as Iterator, but make the iterator infinite by cycling at the end.
Fill this value using the values returned by an iterator.
Warning: the iterator should not end !
Specific OrderedDeclaration computed using a lambda.
Composite of a LazyAttribute and a Sequence.
A factory declaration.
Ordered declarations mark an attribute as needing lazy evaluation. This allows them to refer to attributes defined by other OrderedDeclarations in the same factory.
Evaluate this declaration.
Base class for attributes expecting parameters.
Evaluate the current definition and fill its attributes.
Uses attributes definition in the following order: - values defined when defining the ParameteredAttribute - additional values defined when instantiating the containing factory
Calls a given function once the object has been generated.
Declarations to be called once the target object has been generated.
Call this hook; no return value is expected.
obj (object): the newly generated object create (bool): whether the object was ‘built’ or ‘created’ extracted (object): the value given for <extract_prefix> in the
object definition, or None if not provided.
Extract relevant attributes from a dict.
Calls a method of the generated object.
Calls a factory once the object has been generated.
factory (Factory): the factory to call defaults (dict): extra declarations for calling the related factory name (str): the name to use to refer to the generated object when
calling the related factory
Specific OrderedDeclaration copying values from other fields.
attribute_name (str): the name of the attribute to copy. default (object): the default value to use if the attribute doesn’t
exist.
Specific OrderedDeclaration to use for ‘sequenced’ fields.
These fields are typically used to generate increasing unique values.
Base class for attributes based upon a sub-factory.
factory (base.Factory): the wrapped factory
Try to retrieve the given attribute of an object, digging on ‘.’.
This is an extended getattr, digging deeper if ‘.’ is found.
Builds attributes from a factory and extra data.
_attrs (DeclarationDict): the attribute declarations for the factory _subfields (dict): dict mapping an attribute name to a dict of
overridden default values for the related SubFactory.
Raised when cyclic definition were found.
Slightly extended dict to work with OrderedDeclaration.
Copy this DeclarationDict into another one, including extra values.
A generic container that only allows getting attributes.
Attributes are set at instantiation time, values are computed lazily.
__attrs (dict): maps attribute name to their declaration __values (dict): maps attribute name to computed value __pending (str list): names of the attributes whose value is being
computed. This allows to detect cyclic lazy attribute definition.
__target_class (type): the target class to build.
Lazy wrapper around an OrderedDeclaration.
Alternate DeclarationDict for PostGenerationDeclaration.
Lazy wrapper around a SubFactory.
subfactory (declarations.SubFactory): the SubFactory being wrapped subfields (DeclarationDict): Default values to override when evaluating
the SubFactory
create (bool): whether to ‘create’ or ‘build’ the SubFactory.
Factory base support for sequences, attributes and stubs.
Build a dict of attribute values, respecting declaration order.
The process is: - Handle ‘orderless’ attributes, overriding defaults with provided
kwargs when applicable
applicable; the current list of computed attributes is available to the currently processed object.
Build an instance of the associated class, with overriden attrs.
Build a batch of instances of the given class, with overriden attrs.
Create an instance of the associated class, with overriden attrs.
Create a batch of instances of the given class, with overriden attrs.
Retrieve a copy of the declared attributes.
Generate a new instance.
The instance will be created with the given strategy (one of BUILD_STRATEGY, CREATE_STRATEGY, STUB_STRATEGY).
Generate a batch of instances.
The instances will be created with the given strategy (one of BUILD_STRATEGY, CREATE_STRATEGY, STUB_STRATEGY).
Generate a new instance.
The instance will be either ‘built’ or ‘created’.
Generate a batch of instances.
These instances will be either ‘built’ or ‘created’.
Factory metaclass for handling ordered declarations.
Factory for Django models.
This makes sure that the ‘sequence’ field of created objects is an unused id.
Possible improvement: define a new ‘attribute’ type, AutoField, which would handle those for non-numerical primary keys.
Factory base with build and create support.
This class has the ability to support multiple ORMs by using custom creation functions.
Retrieve the building function for this class.
Retrieve the creation function for this class.
Set the building function for this class.
Set the creation function for this class.
Factory metaclass for handling class association and ordered declarations.
Create a factory for the given class, and build an instance.
Create a factory for the given class, and build a batch of instances.
Create a factory for the given class, and create an instance.
Create a factory for the given class, and create a batch of instances.
Create a factory for the given class, and generate an instance.
Create a factory for the given class, and generate instances.
Retrieve all BaseFactoryMetaClass-derived bases from a list.
Create a new, simple factory for the given class.
Create a factory for the given class, and simple_generate an instance.
Create a factory for the given class, and simple_generate instances.
Create a factory for the given class, and stub an instance.