summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-03-17 02:29:24 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-03-17 02:29:24 +0100
commitdb643d44c51659d9460aa73eb21e7888b22896de (patch)
treeec38350de8e827cc0ff418f7946f3b399ab29e80 /tests
parent84019217057d1752fba021b2bfe940af5636977d (diff)
downloadfactory-boy-db643d44c51659d9460aa73eb21e7888b22896de.tar
factory-boy-db643d44c51659d9460aa73eb21e7888b22896de.tar.gz
Add a '@use_strategy' decorator for forcing alternate strategies.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_base.py b/tests/test_base.py
index 8da655e..a548b56 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -141,6 +141,14 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
TestModelFactory.default_strategy = base.BUILD_STRATEGY
self.assertRaises(base.StubFactory.UnsupportedStrategy, TestModelFactory)
+ def test_change_strategy(self):
+ @base.use_strategy(base.CREATE_STRATEGY)
+ class TestModelFactory(base.StubFactory):
+ one = 'one'
+
+ self.assertEqual(base.CREATE_STRATEGY, TestModelFactory.default_strategy)
+
+
class FactoryCreationTestCase(unittest.TestCase):
def testFactoryFor(self):
class TestFactory(base.Factory):