summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-11-14 23:51:09 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-11-15 00:03:37 +0100
commit048fb1cc935a2ccbc5ca7af81c9390e218a1080b (patch)
treebc1af32ab1dd72a90ea1f7e0b0beba25b96b8714 /factory
parent7fe9c7cc94f6ba69abdf45d09a2dcc8969503514 (diff)
downloadfactory-boy-048fb1cc935a2ccbc5ca7af81c9390e218a1080b.tar
factory-boy-048fb1cc935a2ccbc5ca7af81c9390e218a1080b.tar.gz
Rename ABSTRACT_FACTORY to FACTORY_ABSTRACT.
And add a deprecation warning too. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory')
-rw-r--r--factory/base.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/factory/base.py b/factory/base.py
index dde9f38..3d4e8c1 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -170,7 +170,7 @@ class FactoryMetaClass(BaseFactoryMetaClass):
if FACTORY_CLASS_DECLARATION in attrs:
return attrs[FACTORY_CLASS_DECLARATION]
- # No specific associated calss was given, and one was defined for our
+ # No specific associated class was given, and one was defined for our
# parent, use it.
if inherited is not None:
return inherited
@@ -212,12 +212,21 @@ class FactoryMetaClass(BaseFactoryMetaClass):
for construction of an associated class instance at a later time."""
parent_factories = get_factory_bases(bases)
- if not parent_factories or attrs.get('ABSTRACT_FACTORY', False):
+ if not parent_factories or attrs.get('ABSTRACT_FACTORY', False) \
+ or attrs.get('FACTORY_ABSTRACT', False):
# If this isn't a subclass of Factory, or specifically declared
# abstract, don't do anything special.
if 'ABSTRACT_FACTORY' in attrs:
+ warnings.warn(
+ "The 'ABSTRACT_FACTORY' class attribute has been renamed "
+ "to 'FACTORY_ABSTRACT' for naming consistency, and will "
+ "be ignored in the future. Please upgrade class %s." %
+ class_name, DeprecationWarning, 2)
attrs.pop('ABSTRACT_FACTORY')
+ if 'FACTORY_ABSTRACT' in attrs:
+ attrs.pop('FACTORY_ABSTRACT')
+
return super(FactoryMetaClass, cls).__new__(cls, class_name, bases, attrs)
base = parent_factories[0]
@@ -644,7 +653,7 @@ class DjangoModelFactory(Factory):
handle those for non-numerical primary keys.
"""
- ABSTRACT_FACTORY = True
+ FACTORY_ABSTRACT = True
@classmethod
def _setup_next_sequence(cls):
@@ -662,7 +671,7 @@ class DjangoModelFactory(Factory):
class MogoFactory(Factory):
"""Factory for mogo objects."""
- ABSTRACT_FACTORY = True
+ FACTORY_ABSTRACT = True
def _build(cls, target_class, *args, **kwargs):
return target_class.new(*args, **kwargs)