summaryrefslogtreecommitdiff
path: root/docs/subfactory.rst
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-09 02:16:42 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-09 02:16:42 +0200
commita31e87f19b7c193b980d0f54971c12a60e8c7263 (patch)
tree2ccf86db6921f19363176db6de561a452a212aea /docs/subfactory.rst
parente0e628ec54b8a4d7f41f86f9f535d791a437b13c (diff)
downloadfactory-boy-a31e87f19b7c193b980d0f54971c12a60e8c7263.tar
factory-boy-a31e87f19b7c193b980d0f54971c12a60e8c7263.tar.gz
Introduce 'CircularSubFactory.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'docs/subfactory.rst')
-rw-r--r--docs/subfactory.rst25
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/subfactory.rst b/docs/subfactory.rst
index 1815312..f8642f3 100644
--- a/docs/subfactory.rst
+++ b/docs/subfactory.rst
@@ -54,3 +54,28 @@ Fields of the SubFactory can also be overridden when instantiating the external
<User: Henry Jones>
>>> c.owner.email
henry.jones@example.org
+
+
+Circular dependencies
+---------------------
+
+In order to solve circular dependency issues, Factory Boy provides the :class:`~factory.CircularSubFactory` class.
+
+This class expects a module name and a factory name to import from that module; the given module will be imported
+(as an absolute import) when the factory is first accessed::
+
+ # foo/factories.py
+ import factory
+
+ from bar import factories
+
+ class FooFactory(factory.Factory):
+ bar = factory.SubFactory(factories.BarFactory)
+
+
+ # bar/factories.py
+ import factory
+
+ class BarFactory(factory.Factory):
+ # Avoid circular import
+ foo = factory.CircularSubFactory('foo.factories', 'FooFactory', bar=None)