From 70e961169a14588d223e282387cdbab0cb8a404c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Wed, 3 Aug 2011 18:28:09 +0200 Subject: Allow the definition of 'abstract' factories. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Needs more testing. Signed-off-by: Raphaƫl Barrois --- factory/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'factory/base.py') diff --git a/factory/base.py b/factory/base.py index c474348..cfbfae8 100644 --- a/factory/base.py +++ b/factory/base.py @@ -73,7 +73,7 @@ class BaseFactoryMetaClass(type): an associated class instance at a later time.''' base = get_factory_base(bases) - if not base: + if not base or attrs.get('ABSTRACT_FACTORY', False): # If this isn't a subclass of Factory, don't do anything special. return super(BaseFactoryMetaClass, cls).__new__(cls, class_name, bases, attrs) @@ -100,7 +100,7 @@ class FactoryMetaClass(BaseFactoryMetaClass): for construction of an associated class instance at a later time.''' base = get_factory_base(bases) - if not base: + if not base or attrs.get('ABSTRACT_FACTORY', False): # If this isn't a subclass of Factory, don't do anything special. return super(FactoryMetaClass, cls).__new__(cls, class_name, bases, attrs) @@ -253,6 +253,8 @@ class DjangoModelFactory(Factory): handle those for non-numerical primary keys. """ + ABSTRACT_FACTORY = True + @classmethod def _setup_next_sequence(cls): try: -- cgit v1.2.3