Updated for hfsplus module, new gusi libs.
[python/dscho.git] / Lib / test / test___all__.py
blob4a4103632fb66ed65df9bd5a77c45d0a3f84fce7
1 from test_support import verify, verbose
2 import sys
4 def check_all(modname):
5 names = {}
6 try:
7 exec "import %s" % modname in names
8 except ImportError:
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).
21 try:
22 del sys.modules[modname]
23 except KeyError:
24 pass
25 return
26 verify(hasattr(sys.modules[modname], "__all__"),
27 "%s has no __all__ attribute" % modname)
28 names = {}
29 exec "from %s import *" % modname in names
30 if names.has_key("__builtins__"):
31 del names["__builtins__"]
32 keys = names.keys()
33 keys.sort()
34 all = list(sys.modules[modname].__all__) # in case it's a tuple
35 all.sort()
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.
41 import _socket
43 check_all("BaseHTTPServer")
44 check_all("CGIHTTPServer")
45 check_all("ConfigParser")
46 check_all("Cookie")
47 check_all("MimeWriter")
48 check_all("SimpleHTTPServer")
49 check_all("SocketServer")
50 check_all("StringIO")
51 check_all("UserString")
52 check_all("aifc")
53 check_all("atexit")
54 check_all("audiodev")
55 check_all("base64")
56 check_all("bdb")
57 check_all("binhex")
58 check_all("calendar")
59 check_all("cgi")
60 check_all("cmd")
61 check_all("code")
62 check_all("codecs")
63 check_all("codeop")
64 check_all("colorsys")
65 check_all("commands")
66 check_all("compileall")
67 check_all("copy")
68 check_all("copy_reg")
69 check_all("dbhash")
70 check_all("dircache")
71 check_all("dis")
72 check_all("doctest")
73 check_all("dospath")
74 check_all("filecmp")
75 check_all("fileinput")
76 check_all("fnmatch")
77 check_all("fpformat")
78 check_all("ftplib")
79 check_all("getopt")
80 check_all("getpass")
81 check_all("gettext")
82 check_all("glob")
83 check_all("gopherlib")
84 check_all("gzip")
85 check_all("htmllib")
86 check_all("httplib")
87 check_all("ihooks")
88 check_all("imaplib")
89 check_all("imghdr")
90 check_all("imputil")
91 check_all("keyword")
92 check_all("linecache")
93 check_all("locale")
94 check_all("macpath")
95 check_all("macurl2path")
96 check_all("mailbox")
97 check_all("mhlib")
98 check_all("mimetools")
99 check_all("mimetypes")
100 check_all("mimify")
101 check_all("multifile")
102 check_all("netrc")
103 check_all("nntplib")
104 check_all("ntpath")
105 check_all("os")
106 check_all("pdb")
107 check_all("pickle")
108 check_all("pipes")
109 check_all("popen2")
110 check_all("poplib")
111 check_all("posixpath")
112 check_all("pprint")
113 check_all("pre")
114 check_all("profile")
115 check_all("pstats")
116 check_all("pty")
117 check_all("py_compile")
118 check_all("pyclbr")
119 check_all("quopri")
120 check_all("random")
121 check_all("re")
122 check_all("reconvert")
123 import warnings
124 warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning, "regsub",
125 append=1)
126 check_all("regsub")
127 check_all("repr")
128 check_all("rexec")
129 check_all("rfc822")
130 check_all("rlcompleter")
131 check_all("robotparser")
132 check_all("sched")
133 check_all("sgmllib")
134 check_all("shelve")
135 check_all("shlex")
136 check_all("shutil")
137 check_all("smtpd")
138 check_all("smtplib")
139 check_all("sndhdr")
140 check_all("socket")
141 check_all("sre")
142 check_all("stat_cache")
143 check_all("tabnanny")
144 check_all("telnetlib")
145 check_all("tempfile")
146 check_all("toaiff")
147 check_all("tokenize")
148 check_all("traceback")
149 check_all("tty")
150 check_all("urllib")
151 check_all("urlparse")
152 check_all("uu")
153 check_all("warnings")
154 check_all("wave")
155 check_all("weakref")
156 check_all("webbrowser")
157 check_all("xdrlib")
158 check_all("zipfile")