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