1 from test_support
import verify
, verbose
4 def check_all(modname
):
6 warnings
.filterwarnings("ignore", "", DeprecationWarning, modname
)
10 exec "import %s" % modname
in names
12 # Silent fail here seems the best route since some modules
13 # may not be available in all environments.
14 # Since an ImportError may leave a partial module object in
15 # sys.modules, get rid of that first. Here's what happens if
16 # you don't: importing pty fails on Windows because pty tries to
17 # import FCNTL, which doesn't exist. That raises an ImportError,
18 # caught here. It also leaves a partial pty module in sys.modules.
19 # So when test_pty is called later, the import of pty succeeds,
20 # but shouldn't. As a result, test_pty crashes with an
21 # AtttributeError instead of an ImportError, and regrtest interprets
22 # the latter as a test failure (ImportError is treated as "test
23 # skipped" -- which is what test_pty should say on Windows).
25 del sys
.modules
[modname
]
29 verify(hasattr(sys
.modules
[modname
], "__all__"),
30 "%s has no __all__ attribute" % modname
)
32 exec "from %s import *" % modname
in names
33 if names
.has_key("__builtins__"):
34 del names
["__builtins__"]
37 all
= list(sys
.modules
[modname
].__all
__) # in case it's a tuple
39 verify(keys
==all
, "%s != %s" % (keys
, all
))
41 check_all("BaseHTTPServer")
42 check_all("CGIHTTPServer")
43 check_all("ConfigParser")
45 check_all("MimeWriter")
46 check_all("SimpleHTTPServer")
47 check_all("SocketServer")
49 check_all("UserString")
64 check_all("compileall")
73 check_all("fileinput")
81 check_all("gopherlib")
90 check_all("linecache")
93 check_all("macurl2path")
96 check_all("mimetools")
97 check_all("mimetypes")
99 check_all("multifile")
109 check_all("posixpath")
115 check_all("py_compile")
120 check_all("reconvert")
125 check_all("rlcompleter")
126 check_all("robotparser")
137 check_all("stat_cache")
138 check_all("tabnanny")
139 check_all("telnetlib")
140 check_all("tempfile")
142 check_all("tokenize")
143 check_all("traceback")
146 check_all("urlparse")
148 check_all("warnings")
151 check_all("webbrowser")