From: Brett Cannon Date: Tue, 6 May 2008 23:22:02 +0000 (+0000) Subject: When testing a module's __all__, we really don't care if it is deprecated. X-Git-Tag: v2.6a3~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79618239d144d8e824bac176c95dfb9f0212b224;p=python When testing a module's __all__, we really don't care if it is deprecated. --- diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 571e3912b2..8f12d7cf96 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -1,27 +1,22 @@ import unittest -from test.test_support import run_unittest +from test.test_support import run_unittest, catch_warning import sys import warnings -warnings.filterwarnings("ignore", "the sets module is deprecated", - DeprecationWarning, "") -warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*", - DeprecationWarning) -warnings.filterwarnings("ignore", "the MimeWriter module is deprecated.*", - DeprecationWarning) -warnings.filterwarnings("ignore", "the mimify module is deprecated.*", - DeprecationWarning) + class AllTest(unittest.TestCase): def check_all(self, modname): names = {} - try: - exec "import %s" % modname in names - except ImportError: - # Silent fail here seems the best route since some modules - # may not be available in all environments. - return + with catch_warning(): + warnings.filterwarnings("ignore", ".* module", DeprecationWarning) + try: + exec "import %s" % modname in names + except ImportError: + # Silent fail here seems the best route since some modules + # may not be available in all environments. + return self.failUnless(hasattr(sys.modules[modname], "__all__"), "%s has no __all__ attribute" % modname) names = {}