summaryrefslogtreecommitdiff
path: root/tests/test_using.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-11-14 23:15:55 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-11-15 00:03:37 +0100
commitc86d32b892c383fb18b0a5d7cebc7671e4e88ab1 (patch)
tree2622da13d44f06e819c5705aaf06b22a158143c6 /tests/test_using.py
parentac90ac4b3425cc79c164b3dc0bd13901bf814ff7 (diff)
downloadfactory-boy-c86d32b892c383fb18b0a5d7cebc7671e4e88ab1.tar
factory-boy-c86d32b892c383fb18b0a5d7cebc7671e4e88ab1.tar.gz
Mix SelfAttribute with ContainerAttribute.
With a very simple syntax. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_using.py')
-rw-r--r--tests/test_using.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index ad62113..38c9e9e 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -365,6 +365,23 @@ class UsingFactoryTestCase(unittest.TestCase):
self.assertEqual(3, test_object.four)
self.assertEqual(5, test_object.five)
+ def testSelfAttributeParent(self):
+ class TestModel2(FakeModel):
+ pass
+
+ class TestModelFactory(FakeModelFactory):
+ FACTORY_FOR = TestModel
+ one = 3
+ three = factory.SelfAttribute('..bar')
+
+ class TestModel2Factory(FakeModelFactory):
+ FACTORY_FOR = TestModel2
+ bar = 4
+ two = factory.SubFactory(TestModelFactory, one=1)
+
+ test_model = TestModel2Factory()
+ self.assertEqual(4, test_model.two.three)
+
def testSequenceDecorator(self):
class TestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject