From 6329a894c0b148f1c8bba2ebf224201419cf44ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Fri, 13 Jan 2012 00:01:01 +0100 Subject: Add a PendingDeprecationWarning on associated class auto-discovery. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Barrois --- tests/test_base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_base.py') diff --git a/tests/test_base.py b/tests/test_base.py index 4f77421..8da655e 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -21,6 +21,7 @@ # THE SOFTWARE. import unittest +import warnings from factory import base from factory import declarations @@ -153,6 +154,21 @@ class FactoryCreationTestCase(unittest.TestCase): self.assertTrue(isinstance(TestObjectFactory.build(), TestObject)) + def testDeprecationWarning(self): + """Make sure the 'auto-discovery' deprecation warning is issued.""" + + with warnings.catch_warnings(record=True) as w: + # Clear the warning registry. + if hasattr(base, '__warningregistry__'): + base.__warningregistry__.clear() + + warnings.simplefilter('always') + class TestObjectFactory(base.Factory): + pass + + self.assertEqual(1, len(w)) + self.assertIn('deprecated', str(w[0].message)) + def testStub(self): class TestFactory(base.StubFactory): pass -- cgit v1.2.3