From ebbf350c8594cf5c51ea60d3badbbabbb5a6de68 Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Thu, 16 Aug 2012 20:28:48 +0200 Subject: Add DeprecationWarnings on set_XXX_function. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- factory/base.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3