diff options
author | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2013-04-16 08:10:51 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2013-04-16 08:10:51 +0200 |
commit | 9e17f7ef95f7951d7373d9f0f197dd21ac077725 (patch) | |
tree | 7b703619395135bda43d214569ed3f8cf6d175f6 /tests/test_using.py | |
parent | f35579bd37594b1d888e07db79bdd77a68f4f897 (diff) | |
download | factory-boy-9e17f7ef95f7951d7373d9f0f197dd21ac077725.tar factory-boy-9e17f7ef95f7951d7373d9f0f197dd21ac077725.tar.gz |
Add more tests for DjangoModelFactoryTestCase.
Diffstat (limited to 'tests/test_using.py')
-rw-r--r-- | tests/test_using.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_using.py b/tests/test_using.py index c46bf2f..9e9e6aa 100644 --- a/tests/test_using.py +++ b/tests/test_using.py @@ -1758,5 +1758,26 @@ class ListTestCase(unittest.TestCase): ], ], o.two) + +class DjangoModelFactoryTestCase(unittest.TestCase): + def test_sequence(self): + class TestModelFactory(factory.DjangoModelFactory): + FACTORY_FOR = TestModel + + a = factory.Sequence(lambda n: 'foo_%s' % n) + + o1 = TestModelFactory() + o2 = TestModelFactory() + + self.assertEqual('foo_2', o1.a) + self.assertEqual('foo_3', o2.a) + + o3 = TestModelFactory.build() + o4 = TestModelFactory.build() + + self.assertEqual('foo_4', o3.a) + self.assertEqual('foo_5', o4.a) + + if __name__ == '__main__': unittest.main() |