summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-16 20:28:48 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-16 22:38:43 +0200
commitebbf350c8594cf5c51ea60d3badbbabbb5a6de68 (patch)
tree425d625825c13484e744e396d863ad5f5953e698
parent6efa57cf38f945c55214a94e0e7c12cc7eff474f (diff)
downloadfactory-boy-ebbf350c8594cf5c51ea60d3badbbabbb5a6de68.tar
factory-boy-ebbf350c8594cf5c51ea60d3badbbabbb5a6de68.tar.gz
Add DeprecationWarnings on set_XXX_function.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
-rw-r--r--factory/base.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/factory/base.py b/factory/base.py
index 159a50c..93aacde 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -32,7 +32,12 @@ CREATE_STRATEGY = 'create'
STUB_STRATEGY = 'stub'
# Creation functions. Use Factory.set_creation_function() to set a creation function appropriate for your ORM.
-DJANGO_CREATION = lambda class_to_create, **kwargs: class_to_create.objects.create(**kwargs)
+def DJANGO_CREATION(class_to_create, **kwargs):
+ warnings.warn(
+ "Factories defaulting to Django's Foo.objects.create() is deprecated, "
+ "and will be removed in the future. Please inherit from "
+ "factory.DjangoModelFactory instead.", PendingDeprecationWarning, 6)
+ return class_to_create.objects.create(**kwargs)
# Building functions. Use Factory.set_building_function() to set a building functions appropriate for your ORM.
NAIVE_BUILD = lambda class_to_build, **kwargs: class_to_build(**kwargs)
@@ -505,6 +510,10 @@ class Factory(BaseFactory):
which an instance will be created. The value of the various
fields are passed as keyword arguments.
"""
+ warnings.warn(
+ "Use of factory.set_creation_function is deprecated, and will be "
+ "removed in the future. Please override Factory._create() instead.",
+ PendingDeprecationWarning, 2)
cls._creation_function = (creation_function,)
@classmethod
@@ -543,6 +552,10 @@ class Factory(BaseFactory):
which an instance will be built. The value of the various
fields are passed as keyword arguments.
"""
+ warnings.warn(
+ "Use of factory.set_building_function is deprecated, and will be "
+ "removed in the future. Please override Factory._build() instead.",
+ PendingDeprecationWarning, 2)
cls._building_function = (building_function,)
@classmethod