blob: 3ed22f9a10ee8565e72e8ab504bea4c2cbdcf611 [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
Greg Wardcbce2022001-08-04 22:22:19 +000041# In case _socket fails to build, make this test fail more gracefully
42# than an AttributeError somewhere deep in CGIHTTPServer.
43import _socket
Tim Petersab9ba272001-08-09 21:40:30 +000044
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000045check_all("BaseHTTPServer")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000046check_all("CGIHTTPServer")
47check_all("ConfigParser")
48check_all("Cookie")
49check_all("MimeWriter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000050check_all("SimpleHTTPServer")
51check_all("SocketServer")
52check_all("StringIO")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000053check_all("UserString")
54check_all("aifc")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000055check_all("atexit")
56check_all("audiodev")
57check_all("base64")
58check_all("bdb")
59check_all("binhex")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000060check_all("calendar")
61check_all("cgi")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000062check_all("cmd")
63check_all("code")
64check_all("codecs")
65check_all("codeop")
66check_all("colorsys")
67check_all("commands")
68check_all("compileall")
69check_all("copy")
70check_all("copy_reg")
Skip Montanaro03d90142001-01-25 15:29:22 +000071check_all("dbhash")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000072check_all("dircache")
73check_all("dis")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000074check_all("doctest")
75check_all("dospath")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000076check_all("filecmp")
77check_all("fileinput")
78check_all("fnmatch")
79check_all("fpformat")
80check_all("ftplib")
81check_all("getopt")
82check_all("getpass")
Skip Montanaro2dd42762001-01-23 15:35:05 +000083check_all("gettext")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000084check_all("glob")
Barry Warsaw24f3aca2001-01-24 04:13:02 +000085check_all("gopherlib")
Skip Montanaro2dd42762001-01-23 15:35:05 +000086check_all("gzip")
Skip Montanaro2dd42762001-01-23 15:35:05 +000087check_all("htmllib")
88check_all("httplib")
89check_all("ihooks")
90check_all("imaplib")
Skip Montanaro17ab1232001-01-24 06:27:27 +000091check_all("imghdr")
92check_all("imputil")
93check_all("keyword")
94check_all("linecache")
95check_all("locale")
96check_all("macpath")
97check_all("macurl2path")
98check_all("mailbox")
99check_all("mhlib")
Skip Montanaro03d90142001-01-25 15:29:22 +0000100check_all("mimetools")
101check_all("mimetypes")
102check_all("mimify")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000103check_all("multifile")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000104check_all("netrc")
105check_all("nntplib")
106check_all("ntpath")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000107check_all("os")
Skip Montanaro352674d2001-02-07 23:14:30 +0000108check_all("pdb")
109check_all("pickle")
110check_all("pipes")
111check_all("popen2")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000112check_all("poplib")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000113check_all("posixpath")
114check_all("pprint")
115check_all("pre")
116check_all("profile")
117check_all("pstats")
118check_all("pty")
119check_all("py_compile")
120check_all("pyclbr")
121check_all("quopri")
Skip Montanaro0de65802001-02-15 22:15:14 +0000122check_all("random")
123check_all("re")
124check_all("reconvert")
Skip Montanaro0de65802001-02-15 22:15:14 +0000125check_all("regsub")
126check_all("repr")
127check_all("rexec")
128check_all("rfc822")
129check_all("rlcompleter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +0000130check_all("robotparser")
Skip Montanaro0de65802001-02-15 22:15:14 +0000131check_all("sched")
132check_all("sgmllib")
133check_all("shelve")
134check_all("shlex")
135check_all("shutil")
136check_all("smtpd")
137check_all("smtplib")
138check_all("sndhdr")
139check_all("socket")
140check_all("sre")
Skip Montanaro0de65802001-02-15 22:15:14 +0000141check_all("stat_cache")
Skip Montanaro40fc1602001-03-01 04:27:19 +0000142check_all("tabnanny")
143check_all("telnetlib")
144check_all("tempfile")
145check_all("toaiff")
146check_all("tokenize")
147check_all("traceback")
148check_all("tty")
149check_all("urllib")
150check_all("urlparse")
151check_all("uu")
152check_all("warnings")
153check_all("wave")
154check_all("weakref")
155check_all("webbrowser")
156check_all("xdrlib")
157check_all("zipfile")