summaryrefslogtreecommitdiff
path: root/tests/test_using.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-02 01:33:53 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-03 21:38:46 +0100
commit37621846d541d7afcad52e6dba8281bd1146cf09 (patch)
tree6b361c8f3b9e9d7d95c5324e08d030a555ecf3fc /tests/test_using.py
parentaecf1b73d9c9d653220b6d8825d5eacd2cb6bd74 (diff)
downloadfactory-boy-37621846d541d7afcad52e6dba8281bd1146cf09.tar
factory-boy-37621846d541d7afcad52e6dba8281bd1146cf09.tar.gz
Deprecate the extract_prefix option to PostGeneration.
Introduces a new, call-less syntax for the @post_generation decorator. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_using.py')
-rw-r--r--tests/test_using.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index 2bab8c0..fd8befb 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -1173,6 +1173,25 @@ class PostGenerationTestCase(unittest.TestCase):
one = 1
+ @factory.post_generation
+ def incr_one(self, _create, _increment):
+ self.one += 1
+
+ obj = TestObjectFactory.build()
+ self.assertEqual(2, obj.one)
+ self.assertFalse(hasattr(obj, 'incr_one'))
+
+ obj = TestObjectFactory.build(one=2)
+ self.assertEqual(3, obj.one)
+ self.assertFalse(hasattr(obj, 'incr_one'))
+
+ @tools.disable_warnings
+ def test_post_generation_calling(self):
+ class TestObjectFactory(factory.Factory):
+ FACTORY_FOR = TestObject
+
+ one = 1
+
@factory.post_generation()
def incr_one(self, _create, _increment):
self.one += 1
@@ -1191,7 +1210,7 @@ class PostGenerationTestCase(unittest.TestCase):
one = 1
- @factory.post_generation()
+ @factory.post_generation
def incr_one(self, _create, increment=1):
self.one += increment