1 from test
.test_support
import verify
, verbose
5 warnings
.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning,
7 warnings
.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
9 warnings
.filterwarnings("ignore", ".* statcache .*", DeprecationWarning,
12 def check_all(modname
):
15 exec "import %s" % modname
in names
17 # Silent fail here seems the best route since some modules
18 # may not be available in all environments.
19 # Since an ImportError may leave a partial module object in
20 # sys.modules, get rid of that first. Here's what happens if
21 # you don't: importing pty fails on Windows because pty tries to
22 # import FCNTL, which doesn't exist. That raises an ImportError,
23 # caught here. It also leaves a partial pty module in sys.modules.
24 # So when test_pty is called later, the import of pty succeeds,
25 # but shouldn't. As a result, test_pty crashes with an
26 # AttributeError instead of an ImportError, and regrtest interprets
27 # the latter as a test failure (ImportError is treated as "test
28 # skipped" -- which is what test_pty should say on Windows).
30 del sys
.modules
[modname
]
34 verify(hasattr(sys
.modules
[modname
], "__all__"),
35 "%s has no __all__ attribute" % modname
)
37 exec "from %s import *" % modname
in names
38 if names
.has_key("__builtins__"):
39 del names
["__builtins__"]
42 all
= list(sys
.modules
[modname
].__all
__) # in case it's a tuple
44 verify(keys
==all
, "%s != %s" % (keys
, all
))
46 if not sys
.platform
.startswith('java'):
47 # In case _socket fails to build, make this test fail more gracefully
48 # than an AttributeError somewhere deep in CGIHTTPServer.
51 check_all("BaseHTTPServer")
52 check_all("CGIHTTPServer")
53 check_all("ConfigParser")
55 check_all("MimeWriter")
56 check_all("SimpleHTTPServer")
57 check_all("SocketServer")
59 check_all("UserString")
74 check_all("compileall")
83 check_all("fileinput")
91 check_all("gopherlib")
100 check_all("linecache")
103 check_all("macurl2path")
106 check_all("mimetools")
107 check_all("mimetypes")
109 check_all("multifile")
119 check_all("posixpath")
121 check_all("pre") # deprecated
125 check_all("py_compile")
130 check_all("reconvert")
135 check_all("robotparser")
146 check_all("stat_cache")
147 check_all("tabnanny")
148 check_all("telnetlib")
149 check_all("tempfile")
151 check_all("tokenize")
152 check_all("traceback")
155 check_all("urlparse")
157 check_all("warnings")
160 check_all("webbrowser")
164 # rlcompleter needs special consideration; it import readline which
165 # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-(
167 check_all("rlcompleter")
174 locale
.setlocale(locale
.LC_CTYPE
, 'C')