summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2014-05-18 12:54:39 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2014-05-18 14:18:49 +0200
commitc7b2ac71acd93b5afdf5cb4d958ffa1bbcd464e1 (patch)
treefe6bd4baa7979a0c7796d8920a6093802d44f5c4 /factory
parentd26f41368e7c8936306cf1c34d73fff40d958128 (diff)
downloadfactory-boy-c7b2ac71acd93b5afdf5cb4d958ffa1bbcd464e1.tar
factory-boy-c7b2ac71acd93b5afdf5cb4d958ffa1bbcd464e1.tar.gz
Add DeprecationWarning for FACTORY_* kwargs
Diffstat (limited to 'factory')
-rw-r--r--factory/base.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/factory/base.py b/factory/base.py
index 7db0c76..862556e 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -21,6 +21,7 @@
# THE SOFTWARE.
import logging
+import warnings
from . import containers
from . import declarations
@@ -109,11 +110,21 @@ class FactoryMetaClass(type):
attrs_meta = attrs.pop('Meta', None)
oldstyle_attrs = {}
+ converted_attrs = {}
for old_name, new_name in base_factory._OLDSTYLE_ATTRIBUTES.items():
if old_name in attrs:
- oldstyle_attrs[new_name] = attrs.pop(old_name)
+ oldstyle_attrs[old_name] = new_name
+ converted_attrs[new_name] = attrs.pop(old_name)
if oldstyle_attrs:
- attrs_meta = type('Meta', (object,), oldstyle_attrs)
+ warnings.warn(
+ "Declaring any of %s at class-level is deprecated"
+ " and will be removed in the future. Please set them"
+ " as %s attributes of a 'class Meta' attribute." % (
+ ', '.join(oldstyle_attrs.keys()),
+ ', '.join(oldstyle_attrs.values()),
+ ),
+ PendingDeprecationWarning, 2)
+ attrs_meta = type('Meta', (object,), converted_attrs)
base_meta = resolve_attribute('_meta', bases)
options_class = resolve_attribute('_options_class', bases, FactoryOptions)