blob: b2ea498eb4cab4a23b7b9e84e9eb4a34e43af691 [file] [log] [blame]
Guido van Rossumd0f5e702001-01-22 23:37:04 +00001from test_support import verify, verbose
Skip Montanaroe99d5ea2001-01-20 19:54:20 +00002import sys
3
Guido van Rossumd0f5e702001-01-22 23:37:04 +00004def check_all(modname):
Skip Montanaro0de65802001-02-15 22:15:14 +00005 import warnings
6 warnings.filterwarnings("ignore", "", DeprecationWarning, modname)
7
Guido van Rossumd0f5e702001-01-22 23:37:04 +00008 names = {}
Skip Montanaro03d90142001-01-25 15:29:22 +00009 try:
10 exec "import %s" % modname in names
11 except ImportError:
Tim Peters76c066b2001-02-12 03:27:31 +000012 # 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
Skip Montanaro03d90142001-01-25 15:29:22 +000028 return
Guido van Rossumd0f5e702001-01-22 23:37:04 +000029 verify(hasattr(sys.modules[modname], "__all__"),
30 "%s has no __all__ attribute" % modname)
31 names = {}
32 exec "from %s import *" % modname in names
Skip Montanarocc012e92001-02-07 22:46:55 +000033 if names.has_key("__builtins__"):
34 del names["__builtins__"]
Guido van Rossumd0f5e702001-01-22 23:37:04 +000035 keys = names.keys()
36 keys.sort()
37 all = list(sys.modules[modname].__all__) # in case it's a tuple
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000038 all.sort()
Guido van Rossumd0f5e702001-01-22 23:37:04 +000039 verify(keys==all, "%s != %s" % (keys, all))
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000040
41check_all("BaseHTTPServer")
42check_all("Bastion")
43check_all("CGIHTTPServer")
44check_all("ConfigParser")
45check_all("Cookie")
46check_all("MimeWriter")
47check_all("Queue")
48check_all("SimpleHTTPServer")
49check_all("SocketServer")
50check_all("StringIO")
51check_all("UserDict")
52check_all("UserList")
53check_all("UserString")
54check_all("aifc")
55check_all("anydbm")
56check_all("atexit")
57check_all("audiodev")
58check_all("base64")
59check_all("bdb")
60check_all("binhex")
61check_all("bisect")
62check_all("calendar")
63check_all("cgi")
64check_all("chunk")
65check_all("cmd")
66check_all("code")
67check_all("codecs")
68check_all("codeop")
69check_all("colorsys")
70check_all("commands")
71check_all("compileall")
72check_all("copy")
73check_all("copy_reg")
Skip Montanaro03d90142001-01-25 15:29:22 +000074check_all("dbhash")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000075check_all("dircache")
76check_all("dis")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000077check_all("doctest")
78check_all("dospath")
79check_all("dumbdbm")
80check_all("filecmp")
81check_all("fileinput")
82check_all("fnmatch")
83check_all("fpformat")
84check_all("ftplib")
85check_all("getopt")
86check_all("getpass")
Skip Montanaro2dd42762001-01-23 15:35:05 +000087check_all("gettext")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000088check_all("glob")
Barry Warsaw24f3aca2001-01-24 04:13:02 +000089check_all("gopherlib")
Skip Montanaro2dd42762001-01-23 15:35:05 +000090check_all("gzip")
91check_all("htmlentitydefs")
92check_all("htmllib")
93check_all("httplib")
94check_all("ihooks")
95check_all("imaplib")
Skip Montanaro17ab1232001-01-24 06:27:27 +000096check_all("imghdr")
97check_all("imputil")
98check_all("keyword")
99check_all("linecache")
100check_all("locale")
101check_all("macpath")
102check_all("macurl2path")
103check_all("mailbox")
104check_all("mhlib")
Skip Montanaro03d90142001-01-25 15:29:22 +0000105check_all("mimetools")
106check_all("mimetypes")
107check_all("mimify")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000108check_all("multifile")
109check_all("mutex")
110check_all("netrc")
111check_all("nntplib")
112check_all("ntpath")
113check_all("nturl2path")
114check_all("os")
Skip Montanaro352674d2001-02-07 23:14:30 +0000115check_all("pdb")
116check_all("pickle")
117check_all("pipes")
118check_all("popen2")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000119check_all("poplib")
120check_all("posixfile")
121check_all("posixpath")
122check_all("pprint")
123check_all("pre")
124check_all("profile")
125check_all("pstats")
126check_all("pty")
127check_all("py_compile")
128check_all("pyclbr")
129check_all("quopri")
Skip Montanaro0de65802001-02-15 22:15:14 +0000130check_all("random")
131check_all("re")
132check_all("reconvert")
133check_all("regex_syntax")
134check_all("regsub")
135check_all("repr")
136check_all("rexec")
137check_all("rfc822")
138check_all("rlcompleter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +0000139check_all("robotparser")
Skip Montanaro0de65802001-02-15 22:15:14 +0000140check_all("sched")
141check_all("sgmllib")
142check_all("shelve")
143check_all("shlex")
144check_all("shutil")
145check_all("smtpd")
146check_all("smtplib")
147check_all("sndhdr")
148check_all("socket")
149check_all("sre")
150check_all("sre_compile")
151check_all("sre_constants")
152check_all("sre_parse")
153check_all("stat")
154check_all("stat_cache")
155check_all("statvfs")
156check_all("string")