1 from test_support
import verify
, verbose
4 def check_all(modname
):
7 exec "import %s" % modname
in names
9 # Silent fail here seems the best route since some modules
10 # may not be available in all environments.
11 # Since an ImportError may leave a partial module object in
12 # sys.modules, get rid of that first. Here's what happens if
13 # you don't: importing pty fails on Windows because pty tries to
14 # import FCNTL, which doesn't exist. That raises an ImportError,
15 # caught here. It also leaves a partial pty module in sys.modules.
16 # So when test_pty is called later, the import of pty succeeds,
17 # but shouldn't. As a result, test_pty crashes with an
18 # AttributeError instead of an ImportError, and regrtest interprets
19 # the latter as a test failure (ImportError is treated as "test
20 # skipped" -- which is what test_pty should say on Windows).
22 del sys
.modules
[modname
]
26 verify(hasattr(sys
.modules
[modname
], "__all__"),
27 "%s has no __all__ attribute" % modname
)
29 exec "from %s import *" % modname
in names
30 if names
.has_key("__builtins__"):
31 del names
["__builtins__"]
34 all
= list(sys
.modules
[modname
].__all
__) # in case it's a tuple
36 verify(keys
==all
, "%s != %s" % (keys
, all
))
38 if not sys
.platform
.startswith('java'):
39 # In case _socket fails to build, make this test fail more gracefully
40 # than an AttributeError somewhere deep in CGIHTTPServer.
43 check_all("BaseHTTPServer")
44 check_all("CGIHTTPServer")
45 check_all("ConfigParser")
47 check_all("MimeWriter")
48 check_all("SimpleHTTPServer")
49 check_all("SocketServer")
51 check_all("UserString")
66 check_all("compileall")
75 check_all("fileinput")
83 check_all("gopherlib")
92 check_all("linecache")
95 check_all("macurl2path")
98 check_all("mimetools")
99 check_all("mimetypes")
101 check_all("multifile")
111 check_all("posixpath")
117 check_all("py_compile")
122 check_all("reconvert")
124 warnings
.filterwarnings("ignore", ".* regsub .*", DeprecationWarning, "regsub",
130 check_all("rlcompleter")
131 check_all("robotparser")
142 check_all("stat_cache")
143 check_all("tabnanny")
144 check_all("telnetlib")
145 check_all("tempfile")
147 check_all("tokenize")
148 check_all("traceback")
151 check_all("urlparse")
153 check_all("warnings")
156 check_all("webbrowser")