diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-05-04 01:17:59 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-05-04 01:17:59 +0200 |
commit | d96c651f51b25988235ff79b50c7f9355fb16dd7 (patch) | |
tree | 02972dccdf0301df2e8781d44de47fd7d3b99598 /factory | |
parent | fbd66ede5617a40f73dfb3f518c9887d48ab401e (diff) | |
download | factory-boy-d96c651f51b25988235ff79b50c7f9355fb16dd7.tar factory-boy-d96c651f51b25988235ff79b50c7f9355fb16dd7.tar.gz |
Only absorb dependant arguments for SubFactory fields (Closes #15).
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory')
-rw-r--r-- | factory/containers.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/factory/containers.py b/factory/containers.py index 9f480cc..946fbd3 100644 --- a/factory/containers.py +++ b/factory/containers.py @@ -242,7 +242,13 @@ class AttributeBuilder(object): self.factory = factory self._containers = extra.pop('__containers', None) self._attrs = factory.declarations(extra) - self._subfields = utils.multi_extract_dict(self._attrs.keys(), self._attrs) + + attrs_with_subfields = [k for k, v in self._attrs.items() if self.has_subfields(v)] + + self._subfields = utils.multi_extract_dict(attrs_with_subfields, self._attrs) + + def has_subfields(self, value): + return isinstance(value, declarations.SubFactory) def build(self, create): """Build a dictionary of attributes. |