diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_using.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_using.py b/tests/test_using.py index 0a893c1..3ef5403 100644 --- a/tests/test_using.py +++ b/tests/test_using.py @@ -292,6 +292,19 @@ class SimpleBuildTestCase(unittest.TestCase): self.assertEqual(obj.three, 5) self.assertEqual(obj.four, None) + def test_build_to_dict(self): + # We have a generic factory + class TestObjectFactory(factory.Factory): + class Meta: + model = TestObject + + one = 'one' + two = factory.LazyAttribute(lambda o: o.one * 2) + + # Now, get a dict out of it + obj = factory.build(dict, FACTORY_CLASS=TestObjectFactory) + self.assertEqual({'one': 'one', 'two': 'oneone'}, obj) + class UsingFactoryTestCase(unittest.TestCase): def test_attribute(self): |