blob: 875d99d7444f9fcfb01d461d73479c72c647d5f3 [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):
5 names = {}
Skip Montanaro03d90142001-01-25 15:29:22 +00006 try:
7 exec "import %s" % modname in names
8 except ImportError:
Tim Peters76c066b2001-02-12 03:27:31 +00009 # Silent fail here seems the best route since some modules
10 # may not be available in all environments.
11 # Since an ImportError may leave a partial module object in
12 # sys.modules, get rid of that first. Here's what happens if
13 # you don't: importing pty fails on Windows because pty tries to
14 # import FCNTL, which doesn't exist. That raises an ImportError,
15 # caught here. It also leaves a partial pty module in sys.modules.
16 # So when test_pty is called later, the import of pty succeeds,
17 # but shouldn't. As a result, test_pty crashes with an
18 # AtttributeError instead of an ImportError, and regrtest interprets
19 # the latter as a test failure (ImportError is treated as "test
20 # skipped" -- which is what test_pty should say on Windows).
21 try:
22 del sys.modules[modname]
23 except KeyError:
24 pass
Skip Montanaro03d90142001-01-25 15:29:22 +000025 return
Guido van Rossumd0f5e702001-01-22 23:37:04 +000026 verify(hasattr(sys.modules[modname], "__all__"),
27 "%s has no __all__ attribute" % modname)
28 names = {}
29 exec "from %s import *" % modname in names
Skip Montanarocc012e92001-02-07 22:46:55 +000030 if names.has_key("__builtins__"):
31 del names["__builtins__"]
Guido van Rossumd0f5e702001-01-22 23:37:04 +000032 keys = names.keys()
33 keys.sort()
34 all = list(sys.modules[modname].__all__) # in case it's a tuple
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000035 all.sort()
Guido van Rossumd0f5e702001-01-22 23:37:04 +000036 verify(keys==all, "%s != %s" % (keys, all))
Skip Montanaroe99d5ea2001-01-20 19:54:20 +000037
38check_all("BaseHTTPServer")
39check_all("Bastion")
40check_all("CGIHTTPServer")
41check_all("ConfigParser")
42check_all("Cookie")
43check_all("MimeWriter")
44check_all("Queue")
45check_all("SimpleHTTPServer")
46check_all("SocketServer")
47check_all("StringIO")
48check_all("UserDict")
49check_all("UserList")
50check_all("UserString")
51check_all("aifc")
52check_all("anydbm")
53check_all("atexit")
54check_all("audiodev")
55check_all("base64")
56check_all("bdb")
57check_all("binhex")
58check_all("bisect")
59check_all("calendar")
60check_all("cgi")
61check_all("chunk")
62check_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")
76check_all("dumbdbm")
77check_all("filecmp")
78check_all("fileinput")
79check_all("fnmatch")
80check_all("fpformat")
81check_all("ftplib")
82check_all("getopt")
83check_all("getpass")
Skip Montanaro2dd42762001-01-23 15:35:05 +000084check_all("gettext")
Skip Montanaroeccd02a2001-01-20 23:34:12 +000085check_all("glob")
Barry Warsaw24f3aca2001-01-24 04:13:02 +000086check_all("gopherlib")
Skip Montanaro2dd42762001-01-23 15:35:05 +000087check_all("gzip")
88check_all("htmlentitydefs")
89check_all("htmllib")
90check_all("httplib")
91check_all("ihooks")
92check_all("imaplib")
Skip Montanaro17ab1232001-01-24 06:27:27 +000093check_all("imghdr")
94check_all("imputil")
95check_all("keyword")
96check_all("linecache")
97check_all("locale")
98check_all("macpath")
99check_all("macurl2path")
100check_all("mailbox")
101check_all("mhlib")
Skip Montanaro03d90142001-01-25 15:29:22 +0000102check_all("mimetools")
103check_all("mimetypes")
104check_all("mimify")
Skip Montanaro269b83b2001-02-06 01:07:02 +0000105check_all("multifile")
106check_all("mutex")
107check_all("netrc")
108check_all("nntplib")
109check_all("ntpath")
110check_all("nturl2path")
111check_all("os")
Skip Montanaro352674d2001-02-07 23:14:30 +0000112check_all("pdb")
113check_all("pickle")
114check_all("pipes")
115check_all("popen2")
Skip Montanaroc62c81e2001-02-12 02:00:42 +0000116check_all("poplib")
117check_all("posixfile")
118check_all("posixpath")
119check_all("pprint")
120check_all("pre")
121check_all("profile")
122check_all("pstats")
123check_all("pty")
124check_all("py_compile")
125check_all("pyclbr")
126check_all("quopri")
Skip Montanaroe99d5ea2001-01-20 19:54:20 +0000127check_all("robotparser")