diff options
author | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2011-06-13 11:33:37 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2011-06-13 11:33:37 +0200 |
commit | b832744b70ed811029edb045afc42ea307073c8e (patch) | |
tree | ef6e566f70e7a1004a6d1d875121df9bd12683b5 /factory/test_base.py | |
parent | e16a7e3d15c7b88bceadbbe1d75363103570e2b3 (diff) | |
download | factory-boy-b832744b70ed811029edb045afc42ea307073c8e.tar factory-boy-b832744b70ed811029edb045afc42ea307073c8e.tar.gz |
Add a new type of attribute, SelfAttribute.
Should be used as a shortcut for 'lambda o: o.some_attr' ; most useful in SubFactories.
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
Diffstat (limited to 'factory/test_base.py')
-rw-r--r-- | factory/test_base.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/factory/test_base.py b/factory/test_base.py index 689b56d..b324680 100644 --- a/factory/test_base.py +++ b/factory/test_base.py @@ -115,6 +115,14 @@ class FactoryTestCase(unittest.TestCase): test_object = TestObjectFactory.build() self.assertEqual(test_object.one, 'one') + def testSelfAttribute(self): + class TestObjectFactory(Factory): + one = 'xx' + two = declarations.SelfAttribute('one') + + test_object = TestObjectFactory.build(one=1) + self.assertEqual(1, test_object.two) + def testSequenceDecorator(self): class TestObjectFactory(Factory): @declarations.sequence |