summaryrefslogtreecommitdiff
path: root/tests/test_containers.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_containers.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_containers.py')
-rw-r--r--tests/test_containers.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_containers.py b/tests/test_containers.py
index 55fe576..797c480 100644
--- a/tests/test_containers.py
+++ b/tests/test_containers.py
@@ -316,6 +316,24 @@ class AttributeBuilderTestCase(unittest.TestCase):
ab = containers.AttributeBuilder(FakeFactory, {'one': 4, 'three': la})
self.assertEqual({'one': 4, 'two': 8, 'three': 8}, ab.build(create=False))
+ def test_subfields(self):
+ class FakeInnerFactory(object):
+ pass
+
+ sf = declarations.SubFactory(FakeInnerFactory)
+
+ class FakeFactory(object):
+ @classmethod
+ def declarations(cls, extra):
+ d = {'one': sf, 'two': 2}
+ d.update(extra)
+ return d
+
+ ab = containers.AttributeBuilder(FakeFactory, {'one__blah': 1, 'two__bar': 2})
+ self.assertTrue(ab.has_subfields(sf))
+ self.assertEqual(['one'], ab._subfields.keys())
+ self.assertEqual(2, ab._attrs['two__bar'])
+
def test_sub_factory(self):
pass