1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
import unittest
from test.support import run_unittest, catch_warning
import sys
import warnings
class AllTest(unittest.TestCase):
def check_all(self, modname):
names = {}
with catch_warning():
warnings.filterwarnings("ignore", ".* (module|package)",
DeprecationWarning)
try:
exec("import %s" % modname, names)
except ImportError:
# Silent fail here seems the best route since some modules
# may not be available in all environments.
return
self.failUnless(hasattr(sys.modules[modname], "__all__"),
"%s has no __all__ attribute" % modname)
names = {}
exec("from %s import *" % modname, names)
if "__builtins__" in names:
del names["__builtins__"]
keys = set(names)
all = set(sys.modules[modname].__all__)
self.assertEqual(keys, all)
def test_all(self):
if not sys.platform.startswith('java'):
# In case _socket fails to build, make this test fail more gracefully
# than an AttributeError somewhere deep in CGIHTTPServer.
import _socket
self.check_all("BaseHTTPServer")
self.check_all("CGIHTTPServer")
self.check_all("configparser")
self.check_all("Cookie")
self.check_all("Queue")
self.check_all("SimpleHTTPServer")
self.check_all("socketserver")
self.check_all("aifc")
self.check_all("base64")
self.check_all("bdb")
self.check_all("binhex")
self.check_all("calendar")
self.check_all("collections")
self.check_all("cgi")
self.check_all("cmd")
self.check_all("code")
self.check_all("codecs")
self.check_all("codeop")
self.check_all("colorsys")
self.check_all("commands")
self.check_all("compileall")
self.check_all("copy")
self.check_all("copyreg")
self.check_all("csv")
self.check_all("dbhash")
self.check_all("decimal")
self.check_all("difflib")
self.check_all("dircache")
self.check_all("dis")
self.check_all("doctest")
self.check_all("dummy_thread")
self.check_all("dummy_threading")
self.check_all("filecmp")
self.check_all("fileinput")
self.check_all("fnmatch")
self.check_all("fpformat")
self.check_all("ftplib")
self.check_all("getopt")
self.check_all("getpass")
self.check_all("gettext")
self.check_all("glob")
self.check_all("gzip")
self.check_all("heapq")
self.check_all("htmllib")
self.check_all("httplib")
self.check_all("ihooks")
self.check_all("imaplib")
self.check_all("imghdr")
self.check_all("keyword")
self.check_all("linecache")
self.check_all("locale")
self.check_all("macpath")
self.check_all("macurl2path")
self.check_all("mailbox")
self.check_all("mailcap")
self.check_all("mhlib")
self.check_all("mimetools")
self.check_all("mimetypes")
self.check_all("multifile")
self.check_all("netrc")
self.check_all("nntplib")
self.check_all("ntpath")
self.check_all("opcode")
self.check_all("optparse")
self.check_all("os")
self.check_all("os2emxpath")
self.check_all("pdb")
self.check_all("pickle")
self.check_all("pickletools")
self.check_all("pipes")
self.check_all("poplib")
self.check_all("posixpath")
self.check_all("pprint")
self.check_all("profile")
self.check_all("pstats")
self.check_all("pty")
self.check_all("py_compile")
self.check_all("pyclbr")
self.check_all("quopri")
self.check_all("random")
self.check_all("re")
self.check_all("reprlib")
self.check_all("rfc822")
self.check_all("rlcompleter")
self.check_all("robotparser")
self.check_all("sched")
self.check_all("sgmllib")
self.check_all("shelve")
self.check_all("shlex")
self.check_all("shutil")
self.check_all("smtpd")
self.check_all("smtplib")
self.check_all("sndhdr")
self.check_all("socket")
self.check_all("_strptime")
self.check_all("symtable")
self.check_all("tabnanny")
self.check_all("tarfile")
self.check_all("telnetlib")
self.check_all("tempfile")
self.check_all("textwrap")
self.check_all("threading")
self.check_all("timeit")
self.check_all("tokenize")
self.check_all("traceback")
self.check_all("tty")
self.check_all("unittest")
self.check_all("urllib")
self.check_all("urlparse")
self.check_all("uu")
self.check_all("warnings")
self.check_all("wave")
self.check_all("weakref")
self.check_all("webbrowser")
self.check_all("xdrlib")
self.check_all("zipfile")
# rlcompleter needs special consideration; it import readline which
# initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-(
try:
self.check_all("rlcompleter")
finally:
try:
import locale
except ImportError:
pass
else:
locale.setlocale(locale.LC_CTYPE, 'C')
def test_main():
run_unittest(AllTest)
if __name__ == "__main__":
test_main()
|