summaryrefslogtreecommitdiff
path: root/tests/test_using.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-15 02:21:08 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-15 02:21:08 +0200
commite7a9a87320c78ec05a5d548516fe17c258e6d4c7 (patch)
tree78d92de6e928ded94f7fda979be6f560844aff85 /tests/test_using.py
parent54971381fb31167d1f47b5e705480e044d702602 (diff)
downloadfactory-boy-e7a9a87320c78ec05a5d548516fe17c258e6d4c7.tar
factory-boy-e7a9a87320c78ec05a5d548516fe17c258e6d4c7.tar.gz
Allow overriding the sequence counter.
Diffstat (limited to 'tests/test_using.py')
-rw-r--r--tests/test_using.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index dde0ba7..def49e4 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -346,6 +346,22 @@ class UsingFactoryTestCase(unittest.TestCase):
self.assertEqual('one43', test_object1.one)
self.assertEqual('two43', test_object1.two)
+ def test_sequence_override(self):
+ class TestObjectFactory(factory.Factory):
+ FACTORY_FOR = TestObject
+
+ one = factory.Sequence(lambda n: 'one%d' % n)
+
+ o1 = TestObjectFactory()
+ o2 = TestObjectFactory()
+ o3 = TestObjectFactory(__sequence=42)
+ o4 = TestObjectFactory()
+
+ self.assertEqual('one0', o1.one)
+ self.assertEqual('one1', o2.one)
+ self.assertEqual('one42', o3.one)
+ self.assertEqual('one2', o4.one)
+
def test_custom_create(self):
class TestModelFactory(factory.Factory):
FACTORY_FOR = TestModel