summaryrefslogtreecommitdiff
path: root/tests/test_using.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-05-04 01:17:59 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-05-04 01:17:59 +0200
commitd96c651f51b25988235ff79b50c7f9355fb16dd7 (patch)
tree02972dccdf0301df2e8781d44de47fd7d3b99598 /tests/test_using.py
parentfbd66ede5617a40f73dfb3f518c9887d48ab401e (diff)
downloadfactory-boy-d96c651f51b25988235ff79b50c7f9355fb16dd7.tar
factory-boy-d96c651f51b25988235ff79b50c7f9355fb16dd7.tar.gz
Only absorb dependant arguments for SubFactory fields (Closes #15).
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_using.py')
-rw-r--r--tests/test_using.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index 20acd79..3bb0959 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -868,6 +868,19 @@ class PostGenerationDeclarationTestCase(unittest.TestCase):
self.assertEqual(4, obj.one)
self.assertFalse(hasattr(obj, 'incr_one'))
+ def test_post_generation_extraction_lambda(self):
+
+ def my_lambda(obj, create, extracted, **kwargs):
+ self.assertTrue(isinstance(obj, TestObject))
+ self.assertFalse(create)
+ self.assertEqual(extracted, 42)
+ self.assertEqual(kwargs, {'foo': 13})
+
+ class TestObjectFactory(factory.Factory):
+ bar = factory.PostGeneration(my_lambda)
+
+ obj = TestObjectFactory.build(bar=42, bar__foo=13)
+
def test_related_factory(self):
class TestRelatedObject(object):
def __init__(self, obj=None, one=None, two=None):