summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-04-07 02:14:58 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-04-07 02:14:58 +0200
commit4bcf146c71589f4b225823eb418ee6908b2efb6b (patch)
tree86b997075cf56fa3ac0b9510910c2487995f9a41 /factory
parent0708fc0bbf29e4426075fcedd45a2d41c6271282 (diff)
downloadfactory-boy-4bcf146c71589f4b225823eb418ee6908b2efb6b.tar
factory-boy-4bcf146c71589f4b225823eb418ee6908b2efb6b.tar.gz
Add and document abstract factories (Closes #8).
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory')
-rw-r--r--factory/base.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/factory/base.py b/factory/base.py
index ef782c7..0edf961 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -92,9 +92,8 @@ class BaseFactoryMetaClass(type):
"""
parent_factories = get_factory_bases(bases)
- if not parent_factories or attrs.get('ABSTRACT_FACTORY', False):
- # If this isn't a subclass of Factory, or specifically declared
- # abstract, don't do anything special.
+ if not parent_factories:
+ # If this isn't a subclass of Factory, don't do anything special.
return super(BaseFactoryMetaClass, cls).__new__(cls, class_name, bases, attrs)
declarations = containers.DeclarationDict()
@@ -200,7 +199,11 @@ class FactoryMetaClass(BaseFactoryMetaClass):
parent_factories = get_factory_bases(bases)
if not parent_factories or attrs.get('ABSTRACT_FACTORY', False):
- # If this isn't a subclass of Factory, don't do anything special.
+ # If this isn't a subclass of Factory, or specifically declared
+ # abstract, don't do anything special.
+ if 'ABSTRACT_FACTORY' in attrs:
+ attrs.pop('ABSTRACT_FACTORY')
+
return super(FactoryMetaClass, cls).__new__(cls, class_name, bases, attrs)
base = parent_factories[0]