summaryrefslogtreecommitdiff
path: root/tests/test_using.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-02-24 01:14:30 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-02-24 01:14:30 +0100
commitdc16881ebf674295a3e855bfc4798a0ce8bd94d2 (patch)
tree2e379c8814c41784945968f0229b117217aad10a /tests/test_using.py
parent3663c1090f6ce016ebc0e9266c4cd4e85796984b (diff)
downloadfactory-boy-dc16881ebf674295a3e855bfc4798a0ce8bd94d2.tar
factory-boy-dc16881ebf674295a3e855bfc4798a0ce8bd94d2.tar.gz
Improve the 'SelfAttribute' syntax.v1.1.0
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_using.py')
-rw-r--r--tests/test_using.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index a93c968..85a12ca 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -27,11 +27,12 @@ import factory
class TestObject(object):
- def __init__(self, one=None, two=None, three=None, four=None):
+ def __init__(self, one=None, two=None, three=None, four=None, five=None):
self.one = one
self.two = two
self.three = three
self.four = four
+ self.five = five
class FakeDjangoModel(object):
class FakeDjangoManager(object):
@@ -164,12 +165,21 @@ class FactoryTestCase(unittest.TestCase):
self.assertEqual(test_object.one, 'one')
def testSelfAttribute(self):
+ class TmpObj(object):
+ n = 3
+
class TestObjectFactory(factory.Factory):
one = 'xx'
two = factory.SelfAttribute('one')
+ three = TmpObj()
+ four = factory.SelfAttribute('three.n')
+ five = factory.SelfAttribute('three.nnn', 5)
test_object = TestObjectFactory.build(one=1)
self.assertEqual(1, test_object.two)
+ self.assertEqual(3, test_object.three.n)
+ self.assertEqual(3, test_object.four)
+ self.assertEqual(5, test_object.five)
def testSequenceDecorator(self):
class TestObjectFactory(factory.Factory):