Commits

Anonymous committed 9eab35e

Added readme note for double underscore syntax for subobject assignment

Comments (0)

Files changed (1)

         assert f.bug2.product.name == 'product-0'
 
 
+Configuring subobjects
+-----------------------
+
+The double underscore syntax lets you specify attributes of child factories on
+the parent. Suppose you have an factories for two different model classes::
+
+    author_factory = Factory(Author, name=Seq('author-#%d'))
+    book_factory = Factory(Book, name=Seq('book-%d'), author=author_factory())
+
+Now you can write a fixture like this::
+
+    class MyFixture(Fixture):
+
+        player = book_factory(name='Animal Farm', author__name='Orwell')
+
 Post-creation configuration
 ---------------------------