summaryrefslogtreecommitdiff
path: root/tests/test_using.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_using.py')
-rw-r--r--tests/test_using.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index 3bb0959..b5687b5 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -616,7 +616,7 @@ class SubFactoryTestCase(unittest.TestCase):
self.assertEqual('x0x', test_model.two.one)
self.assertEqual('x0xx0x', test_model.two.two)
- def testSubFactoryOverriding(self):
+ def testSubFactoryAndSequence(self):
class TestObject(object):
def __init__(self, **kwargs):
for k, v in kwargs.iteritems():
@@ -625,9 +625,36 @@ class SubFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject
+ one = factory.Sequence(lambda n: int(n))
+
class WrappingTestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject
+ wrapped = factory.SubFactory(TestObjectFactory)
+
+ wrapping = WrappingTestObjectFactory.build()
+ self.assertEqual(0, wrapping.wrapped.one)
+ wrapping = WrappingTestObjectFactory.build()
+ self.assertEqual(1, wrapping.wrapped.one)
+
+ def testSubFactoryOverriding(self):
+ class TestObject(object):
+ def __init__(self, **kwargs):
+ for k, v in kwargs.iteritems():
+ setattr(self, k, v)
+
+ class TestObjectFactory(factory.Factory):
+ FACTORY_FOR = TestObject
+
+
+ class OtherTestObject(object):
+ def __init__(self, **kwargs):
+ for k, v in kwargs.iteritems():
+ setattr(self, k, v)
+
+ class WrappingTestObjectFactory(factory.Factory):
+ FACTORY_FOR = OtherTestObject
+
wrapped = factory.SubFactory(TestObjectFactory, two=2, four=4)
wrapped__two = 4
wrapped__three = 3