diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-04-15 02:21:08 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-04-15 02:21:08 +0200 |
commit | e7a9a87320c78ec05a5d548516fe17c258e6d4c7 (patch) | |
tree | 78d92de6e928ded94f7fda979be6f560844aff85 /tests/test_using.py | |
parent | 54971381fb31167d1f47b5e705480e044d702602 (diff) | |
download | factory-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.py | 16 |
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 |