blob: 2cc021b47d5123e84715e4a151e92ecc680f916a [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")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000042check_all("CGIHTTPServer")
43check_all("ConfigParser")
44check_all("Cookie")
45check_all("MimeWriter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000046check_all("SimpleHTTPServer")
47check_all("SocketServer")
48check_all("StringIO")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000049check_all("UserString")
50check_all("aifc")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000051check_all("atexit")
52check_all("audiodev")
53check_all("base64")
54check_all("bdb")
55check_all("binhex")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000056check_all("calendar")
57check_all("cgi")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000058check_all("cmd")
59check_all("code")
60check_all("codecs")
61check_all("codeop")
62check_all("colorsys")
63check_all("commands")
64check_all("compileall")
65check_all("copy")
66check_all("copy_reg")
Skip Montanaro03d90142001-01-25 15:29:22 +000067check_all("dbhash")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000068check_all("dircache")
69check_all("dis")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000070check_all("doctest")
71check_all("dospath")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000072check_all("filecmp")
73check_all("fileinput")
74check_all("fnmatch")
75check_all("fpformat")
76check_all("ftplib")
77check_all("getopt")
78check_all("getpass")
Skip Montanaro2dd42762001-01-23 15:35:05 +000079check_all("gettext")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000080check_all("glob")
Barry Warsaw24f3aca2001-01-24 04:13:02 +000081check_all("gopherlib")
Skip Montanaro2dd42762001-01-23 15:35:05 +000082check_all("gzip")
Skip Montanaro2dd42762001-01-23 15:35:05 +000083check_all("htmllib")
84check_all("httplib")
85check_all("ihooks")
86check_all("imaplib")
Skip Montanaro17ab1232001-01-24 06:27:27 +000087check_all("imghdr")
88check_all("imputil")
89check_all("keyword")
90check_all("linecache")
91check_all("locale")
92check_all("macpath")
93check_all("macurl2path")
94check_all("mailbox")
95check_all("mhlib")
Skip Montanaro03d90142001-01-25 15:29:22 +000096check_all("mimetools")
97check_all("mimetypes")
98check_all("mimify")
Skip Montanaro269b83b2001-02-06 01:07:02 +000099check_all("multifile")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000100check_all("netrc")
101check_all("nntplib")
102check_all("ntpath")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000103check_all("os")
Skip Montanaro352674d2001-02-07 23:14:30 +0000104check_all("pdb")
105check_all("pickle")
106check_all("pipes")
107check_all("popen2")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000108check_all("poplib")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000109check_all("posixpath")
110check_all("pprint")
111check_all("pre")
112check_all("profile")
113check_all("pstats")
114check_all("pty")
115check_all("py_compile")
116check_all("pyclbr")
117check_all("quopri")
Skip Montanaro0de65802001-02-15 22:15:14 +0000118check_all("random")
119check_all("re")
120check_all("reconvert")
Skip Montanaro0de65802001-02-15 22:15:14 +0000121check_all("regsub")
122check_all("repr")
123check_all("rexec")
124check_all("rfc822")
125check_all("rlcompleter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +0000126check_all("robotparser")
Skip Montanaro0de65802001-02-15 22:15:14 +0000127check_all("sched")
128check_all("sgmllib")
129check_all("shelve")
130check_all("shlex")
131check_all("shutil")
132check_all("smtpd")
133check_all("smtplib")
134check_all("sndhdr")
135check_all("socket")
136check_all("sre")
Skip Montanaro0de65802001-02-15 22:15:14 +0000137check_all("stat_cache")
Skip Montanaro40fc1602001-03-01 04:27:19 +0000138check_all("tabnanny")
139check_all("telnetlib")
140check_all("tempfile")
141check_all("toaiff")
142check_all("tokenize")
143check_all("traceback")
144check_all("tty")
145check_all("urllib")
146check_all("urlparse")
147check_all("uu")
148check_all("warnings")
149check_all("wave")
150check_all("weakref")
151check_all("webbrowser")
152check_all("xdrlib")
153check_all("zipfile")