diff options
Diffstat (limited to 'factory')
-rw-r--r-- | factory/containers.py | 4 | ||||
-rw-r--r-- | factory/declarations.py | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/factory/containers.py b/factory/containers.py index ef97548..fda9073 100644 --- a/factory/containers.py +++ b/factory/containers.py @@ -45,6 +45,10 @@ class LazyStub(object): __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. + __containers (LazyStub list): "parents" of the LazyStub being built. + This allows to have the field of a field depend on the value of + another field + __target_class (type): the target class to build. """ __initialized = False diff --git a/factory/declarations.py b/factory/declarations.py index 60425c3..08598e5 100644 --- a/factory/declarations.py +++ b/factory/declarations.py @@ -155,8 +155,9 @@ class ContainerAttribute(OrderedDeclaration): Args: obj (LazyStub): a lazy stub of the object being constructed, if needed. - containers (LazyStub): a lazy stub of a factory being evaluated, with - a SubFactory building 'obj'. + containers (list of LazyStub): a list of lazy stubs of factories + being evaluated in a chain, each item being a future field of + next one. """ if self.strict and not containers: raise TypeError( @@ -187,6 +188,14 @@ class SubFactory(OrderedDeclaration): - attributes defined in the wrapped factory class - values defined when defining the SubFactory - additional values defined in attributes + + Args: + create (bool): whether the subfactory should call 'build' or + 'create' + extra (containers.DeclarationDict): extra values that should + override the wrapped factory's defaults + containers (list of LazyStub): List of LazyStub for the chain of + factories being evaluated, the calling stub being first. """ defaults = dict(self.defaults) |