blob: 299054f838763945ef6aabaf3bbd14b9ca660041 [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
Tim Petersb05cd492002-04-11 20:04:12 +00003import warnings
4
5warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning)
6warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning)
7warnings.filterwarnings("ignore", ".* statcache .*", DeprecationWarning)
Skip Montanaroe99d5ea2001-01-20 19:54:20 +00008
Guido van Rossumd0f5e702001-01-22 23:37:04 +00009def check_all(modname):
10 names = {}
Skip Montanaro03d90142001-01-25 15:29:22 +000011 try:
12 exec "import %s" % modname in names
13 except ImportError:
Tim Peters76c066b2001-02-12 03:27:31 +000014 # Silent fail here seems the best route since some modules
15 # may not be available in all environments.
16 # Since an ImportError may leave a partial module object in
17 # sys.modules, get rid of that first. Here's what happens if
18 # you don't: importing pty fails on Windows because pty tries to
19 # import FCNTL, which doesn't exist. That raises an ImportError,
20 # caught here. It also leaves a partial pty module in sys.modules.
21 # So when test_pty is called later, the import of pty succeeds,
22 # but shouldn't. As a result, test_pty crashes with an
Andrew M. Kuchlinga2085cb2001-11-02 21:45:39 +000023 # AttributeError instead of an ImportError, and regrtest interprets
Tim Peters76c066b2001-02-12 03:27:31 +000024 # the latter as a test failure (ImportError is treated as "test
25 # skipped" -- which is what test_pty should say on Windows).
26 try:
27 del sys.modules[modname]
28 except KeyError:
29 pass
Skip Montanaro03d90142001-01-25 15:29:22 +000030 return
Guido van Rossumd0f5e702001-01-22 23:37:04 +000031 verify(hasattr(sys.modules[modname], "__all__"),
32 "%s has no __all__ attribute" % modname)
33 names = {}
34 exec "from %s import *" % modname in names
Skip Montanarocc012e92001-02-07 22:46:55 +000035 if names.has_key("__builtins__"):
36 del names["__builtins__"]
Guido van Rossumd0f5e702001-01-22 23:37:04 +000037 keys = names.keys()
38 keys.sort()
39 all = list(sys.modules[modname].__all__) # in case it's a tuple
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000040 all.sort()
Guido van Rossumd0f5e702001-01-22 23:37:04 +000041 verify(keys==all, "%s != %s" % (keys, all))
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000042
Tim Peterscbfc0342001-12-07 21:35:42 +000043if not sys.platform.startswith('java'):
44 # In case _socket fails to build, make this test fail more gracefully
45 # than an AttributeError somewhere deep in CGIHTTPServer.
46 import _socket
Tim Petersab9ba272001-08-09 21:40:30 +000047
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000048check_all("BaseHTTPServer")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000049check_all("CGIHTTPServer")
50check_all("ConfigParser")
51check_all("Cookie")
52check_all("MimeWriter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000053check_all("SimpleHTTPServer")
54check_all("SocketServer")
55check_all("StringIO")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000056check_all("UserString")
57check_all("aifc")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000058check_all("atexit")
59check_all("audiodev")
60check_all("base64")
61check_all("bdb")
62check_all("binhex")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000063check_all("calendar")
64check_all("cgi")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000065check_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")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000079check_all("filecmp")
80check_all("fileinput")
81check_all("fnmatch")
82check_all("fpformat")
83check_all("ftplib")
84check_all("getopt")
85check_all("getpass")
Skip Montanaro2dd42762001-01-23 15:35:05 +000086check_all("gettext")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000087check_all("glob")
Barry Warsaw24f3aca2001-01-24 04:13:02 +000088check_all("gopherlib")
Skip Montanaro2dd42762001-01-23 15:35:05 +000089check_all("gzip")
Skip Montanaro2dd42762001-01-23 15:35:05 +000090check_all("htmllib")
91check_all("httplib")
92check_all("ihooks")
93check_all("imaplib")
Skip Montanaro17ab1232001-01-24 06:27:27 +000094check_all("imghdr")
95check_all("imputil")
96check_all("keyword")
97check_all("linecache")
98check_all("locale")
99check_all("macpath")
100check_all("macurl2path")
101check_all("mailbox")
102check_all("mhlib")
Skip Montanaro03d90142001-01-25 15:29:22 +0000103check_all("mimetools")
104check_all("mimetypes")
105check_all("mimify")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000106check_all("multifile")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000107check_all("netrc")
108check_all("nntplib")
109check_all("ntpath")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000110check_all("os")
Skip Montanaro352674d2001-02-07 23:14:30 +0000111check_all("pdb")
112check_all("pickle")
113check_all("pipes")
114check_all("popen2")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000115check_all("poplib")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000116check_all("posixpath")
117check_all("pprint")
Tim Petersb05cd492002-04-11 20:04:12 +0000118check_all("pre") # deprecated
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000119check_all("profile")
120check_all("pstats")
121check_all("pty")
122check_all("py_compile")
123check_all("pyclbr")
124check_all("quopri")
Skip Montanaro0de65802001-02-15 22:15:14 +0000125check_all("random")
126check_all("re")
127check_all("reconvert")
Skip Montanaro0de65802001-02-15 22:15:14 +0000128check_all("regsub")
129check_all("repr")
130check_all("rexec")
131check_all("rfc822")
132check_all("rlcompleter")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +0000133check_all("robotparser")
Skip Montanaro0de65802001-02-15 22:15:14 +0000134check_all("sched")
135check_all("sgmllib")
136check_all("shelve")
137check_all("shlex")
138check_all("shutil")
139check_all("smtpd")
140check_all("smtplib")
141check_all("sndhdr")
142check_all("socket")
143check_all("sre")
Skip Montanaro0de65802001-02-15 22:15:14 +0000144check_all("stat_cache")
Skip Montanaro40fc1602001-03-01 04:27:19 +0000145check_all("tabnanny")
146check_all("telnetlib")
147check_all("tempfile")
148check_all("toaiff")
149check_all("tokenize")
150check_all("traceback")
151check_all("tty")
152check_all("urllib")
153check_all("urlparse")
154check_all("uu")
155check_all("warnings")
156check_all("wave")
157check_all("weakref")
158check_all("webbrowser")
159check_all("xdrlib")
160check_all("zipfile")