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

This commit is contained in:
Brett Cannon 2008-05-06 23:22:02 +00:00
parent af748c3ab8
commit 79618239d1
1 changed files with 10 additions and 15 deletions

View File

@ -1,27 +1,22 @@
import unittest import unittest
from test.test_support import run_unittest from test.test_support import run_unittest, catch_warning
import sys import sys
import warnings 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): class AllTest(unittest.TestCase):
def check_all(self, modname): def check_all(self, modname):
names = {} names = {}
try: with catch_warning():
exec "import %s" % modname in names warnings.filterwarnings("ignore", ".* module", DeprecationWarning)
except ImportError: try:
# Silent fail here seems the best route since some modules exec "import %s" % modname in names
# may not be available in all environments. except ImportError:
return # 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__"), self.failUnless(hasattr(sys.modules[modname], "__all__"),
"%s has no __all__ attribute" % modname) "%s has no __all__ attribute" % modname)
names = {} names = {}