[Python-checkins] r62792 - python/trunk/Lib/test/test___all__.py

brett.cannon python-checkins at python.org
Wed May 7 01:22:02 CEST 2008


Author: brett.cannon
Date: Wed May  7 01:22:02 2008
New Revision: 62792

Log:
When testing a module's __all__, we really don't care if it is deprecated.


Modified:
   python/trunk/Lib/test/test___all__.py

Modified: python/trunk/Lib/test/test___all__.py
==============================================================================
--- python/trunk/Lib/test/test___all__.py	(original)
+++ python/trunk/Lib/test/test___all__.py	Wed May  7 01:22:02 2008
@@ -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, "<string>")
-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 = {}


More information about the Python-checkins mailing list