summaryrefslogtreecommitdiff
path: root/factory/base.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2011-08-03 18:28:09 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2011-08-03 18:28:09 +0200
commit70e961169a14588d223e282387cdbab0cb8a404c (patch)
tree1f42946b59ae9433ec0045cd5c15531a81a42870 /factory/base.py
parent720371777ff8cf3e5d299398d530b948034a228a (diff)
downloadfactory-boy-70e961169a14588d223e282387cdbab0cb8a404c.tar
factory-boy-70e961169a14588d223e282387cdbab0cb8a404c.tar.gz
Allow the definition of 'abstract' factories.
Needs more testing. Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
Diffstat (limited to 'factory/base.py')
-rw-r--r--factory/base.py6
1 files changed, 4 insertions, 2 deletions
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: