From d96c651f51b25988235ff79b50c7f9355fb16dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Fri, 4 May 2012 01:17:59 +0200 Subject: Only absorb dependant arguments for SubFactory fields (Closes #15). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Barrois --- tests/test_containers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test_containers.py') 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 -- cgit v1.2.3