summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2011-05-16 15:32:05 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2011-05-16 15:32:05 +0200
commite42516b995053d0d5f8d4d13a94cea4953ea1850 (patch)
tree88ee97bc82460f2c7d2b7a06ff3c131cd5e70f47 /factory
parente3ec551cc6895a40e0cb1167e06fa4fba71a2a7c (diff)
downloadfactory-boy-e42516b995053d0d5f8d4d13a94cea4953ea1850.tar
factory-boy-e42516b995053d0d5f8d4d13a94cea4953ea1850.tar.gz
Prevent inherited classes from affecting superclasses.
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
Diffstat (limited to 'factory')
-rw-r--r--factory/base.py2
-rw-r--r--factory/test_base.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/factory/base.py b/factory/base.py
index 733b130..d38c82d 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -77,7 +77,7 @@ class BaseFactoryMetaClass(type):
# If this isn't a subclass of Factory, don't do anything special.
return super(BaseFactoryMetaClass, cls).__new__(cls, class_name, bases, attrs)
- declarations = getattr(base, CLASS_ATTRIBUTE_DECLARATIONS, DeclarationsHolder())
+ declarations = DeclarationsHolder(defaults=getattr(base, CLASS_ATTRIBUTE_DECLARATIONS, {}))
attrs = declarations.update_base(attrs)
attrs[CLASS_ATTRIBUTE_DECLARATIONS] = declarations
diff --git a/factory/test_base.py b/factory/test_base.py
index aa8257b..3909a69 100644
--- a/factory/test_base.py
+++ b/factory/test_base.py
@@ -176,6 +176,9 @@ class FactoryTestCase(unittest.TestCase):
self.assertEqual(test_object.three, 'three')
self.assertEqual(test_object.four, 'three four')
+ test_object_alt = TestObjectFactory.build()
+ self.assertEqual(None, test_object_alt.three)
+
def testInheritanceWithInheritedClass(self):
class TestObjectFactory(Factory):
one = 'one'