2 from test
import test_support
4 from test
.test_support
import verify
, verbose
8 warnings
.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning,
10 warnings
.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
12 warnings
.filterwarnings("ignore", ".* statcache .*", DeprecationWarning,
15 class AllTest(unittest
.TestCase
):
17 def check_all(self
, modname
):
20 exec "import %s" % modname
in names
22 # Silent fail here seems the best route since some modules
23 # may not be available in all environments.
24 # Since an ImportError may leave a partial module object in
25 # sys.modules, get rid of that first. Here's what happens if
26 # you don't: importing pty fails on Windows because pty tries to
27 # import FCNTL, which doesn't exist. That raises an ImportError,
28 # caught here. It also leaves a partial pty module in sys.modules.
29 # So when test_pty is called later, the import of pty succeeds,
30 # but shouldn't. As a result, test_pty crashes with an
31 # AttributeError instead of an ImportError, and regrtest interprets
32 # the latter as a test failure (ImportError is treated as "test
33 # skipped" -- which is what test_pty should say on Windows).
35 del sys
.modules
[modname
]
39 verify(hasattr(sys
.modules
[modname
], "__all__"),
40 "%s has no __all__ attribute" % modname
)
42 exec "from %s import *" % modname
in names
43 if names
.has_key("__builtins__"):
44 del names
["__builtins__"]
47 all
= list(sys
.modules
[modname
].__all
__) # in case it's a tuple
49 verify(keys
==all
, "%s != %s" % (keys
, all
))
52 if not sys
.platform
.startswith('java'):
53 # In case _socket fails to build, make this test fail more gracefully
54 # than an AttributeError somewhere deep in CGIHTTPServer.
57 self
.check_all("BaseHTTPServer")
58 self
.check_all("CGIHTTPServer")
59 self
.check_all("ConfigParser")
60 self
.check_all("Cookie")
61 self
.check_all("MimeWriter")
62 self
.check_all("SimpleHTTPServer")
63 self
.check_all("SocketServer")
64 self
.check_all("StringIO")
65 self
.check_all("UserString")
66 self
.check_all("aifc")
67 self
.check_all("atexit")
68 self
.check_all("audiodev")
69 self
.check_all("base64")
71 self
.check_all("binhex")
72 self
.check_all("calendar")
75 self
.check_all("code")
76 self
.check_all("codecs")
77 self
.check_all("codeop")
78 self
.check_all("colorsys")
79 self
.check_all("commands")
80 self
.check_all("compileall")
81 self
.check_all("copy")
82 self
.check_all("copy_reg")
83 self
.check_all("dbhash")
84 self
.check_all("difflib")
85 self
.check_all("dircache")
87 self
.check_all("doctest")
88 self
.check_all("dummy_thread")
89 self
.check_all("dummy_threading")
90 self
.check_all("filecmp")
91 self
.check_all("fileinput")
92 self
.check_all("fnmatch")
93 self
.check_all("fpformat")
94 self
.check_all("ftplib")
95 self
.check_all("getopt")
96 self
.check_all("getpass")
97 self
.check_all("gettext")
98 self
.check_all("glob")
99 self
.check_all("gopherlib")
100 self
.check_all("gzip")
101 self
.check_all("heapq")
102 self
.check_all("htmllib")
103 self
.check_all("httplib")
104 self
.check_all("ihooks")
105 self
.check_all("imaplib")
106 self
.check_all("imghdr")
107 self
.check_all("imputil")
108 self
.check_all("keyword")
109 self
.check_all("linecache")
110 self
.check_all("locale")
111 self
.check_all("macpath")
112 self
.check_all("macurl2path")
113 self
.check_all("mailbox")
114 self
.check_all("mailcap")
115 self
.check_all("mhlib")
116 self
.check_all("mimetools")
117 self
.check_all("mimetypes")
118 self
.check_all("mimify")
119 self
.check_all("multifile")
120 self
.check_all("netrc")
121 self
.check_all("nntplib")
122 self
.check_all("ntpath")
123 self
.check_all("opcode")
125 self
.check_all("os2emxpath")
126 self
.check_all("pdb")
127 self
.check_all("pickle")
128 self
.check_all("pipes")
129 self
.check_all("popen2")
130 self
.check_all("poplib")
131 self
.check_all("posixpath")
132 self
.check_all("pprint")
133 self
.check_all("pre") # deprecated
134 self
.check_all("profile")
135 self
.check_all("pstats")
136 self
.check_all("pty")
137 self
.check_all("py_compile")
138 self
.check_all("pyclbr")
139 self
.check_all("quopri")
140 self
.check_all("random")
142 self
.check_all("reconvert")
143 self
.check_all("regsub")
144 self
.check_all("repr")
145 self
.check_all("rexec")
146 self
.check_all("rfc822")
147 self
.check_all("robotparser")
148 self
.check_all("sched")
149 self
.check_all("sets")
150 self
.check_all("sgmllib")
151 self
.check_all("shelve")
152 self
.check_all("shlex")
153 self
.check_all("shutil")
154 self
.check_all("smtpd")
155 self
.check_all("smtplib")
156 self
.check_all("sndhdr")
157 self
.check_all("socket")
158 self
.check_all("sre")
159 self
.check_all("statcache")
160 self
.check_all("symtable")
161 self
.check_all("tabnanny")
162 self
.check_all("tarfile")
163 self
.check_all("telnetlib")
164 self
.check_all("tempfile")
165 self
.check_all("textwrap")
166 self
.check_all("threading")
167 self
.check_all("toaiff")
168 self
.check_all("tokenize")
169 self
.check_all("traceback")
170 self
.check_all("tty")
171 self
.check_all("urllib")
172 self
.check_all("urlparse")
174 self
.check_all("warnings")
175 self
.check_all("wave")
176 self
.check_all("weakref")
177 self
.check_all("webbrowser")
178 self
.check_all("xdrlib")
179 self
.check_all("zipfile")
181 # rlcompleter needs special consideration; it import readline which
182 # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-(
184 self
.check_all("rlcompleter")
191 locale
.setlocale(locale
.LC_CTYPE
, 'C')
195 suite
= unittest
.TestSuite()
196 suite
.addTest(unittest
.makeSuite(AllTest
))
197 test_support
.run_suite(suite
)
199 if __name__
== "__main__":