summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-16 19:01:07 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-16 22:38:42 +0200
commitdf0b1124cbb9f244dc40f435410ec16462a8fc9b (patch)
treeb11e2a4de14cb1c80bf596ec891b38c1f50cf00a
parentbe6227b52ac07b8df58f0f393026f3c4d51078a0 (diff)
downloadfactory-boy-df0b1124cbb9f244dc40f435410ec16462a8fc9b.tar
factory-boy-df0b1124cbb9f244dc40f435410ec16462a8fc9b.tar.gz
Mark automatic associated class discovery as deprecated.
Also improve warning reporting. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
-rw-r--r--factory/base.py2
-rw-r--r--tests/test_base.py9
2 files changed, 6 insertions, 5 deletions
diff --git a/factory/base.py b/factory/base.py
index c1dbd98..8ff6151 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -182,7 +182,7 @@ class FactoryMetaClass(BaseFactoryMetaClass):
FACTORY_CLASS_DECLARATION,
associated_name,
class_name,
- ), PendingDeprecationWarning)
+ ), DeprecationWarning, 3)
return getattr(factory_module, associated_name)
diff --git a/tests/test_base.py b/tests/test_base.py
index f8ba605..5cbb31b 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -176,8 +176,10 @@ class FactoryCreationTestCase(unittest.TestCase):
self.assertTrue(isinstance(TestFactory.build(), TestObject))
def testAutomaticAssociatedClassDiscovery(self):
- class TestObjectFactory(base.Factory):
- pass
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore')
+ class TestObjectFactory(base.Factory):
+ pass
self.assertTrue(isinstance(TestObjectFactory.build(), TestObject))
@@ -186,8 +188,7 @@ class FactoryCreationTestCase(unittest.TestCase):
with warnings.catch_warnings(record=True) as w:
# Clear the warning registry.
- if hasattr(base, '__warningregistry__'):
- base.__warningregistry__.clear()
+ __warningregistry__.clear()
warnings.simplefilter('always')
class TestObjectFactory(base.Factory):