From 4bcf146c71589f4b225823eb418ee6908b2efb6b Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Sat, 7 Apr 2012 02:14:58 +0200 Subject: Add and document abstract factories (Closes #8). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- factory/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'factory') 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] -- cgit v1.2.3