| 
									
										
										
										
											2001-01-22 23:37:04 +00:00
										 |  |  | from test_support import verify, verbose | 
					
						
							| 
									
										
										
										
											2001-01-20 19:54:20 +00:00
										 |  |  | import sys | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-22 23:37:04 +00:00
										 |  |  | def check_all(modname): | 
					
						
							| 
									
										
										
										
											2001-02-15 22:15:14 +00:00
										 |  |  |     import warnings | 
					
						
							|  |  |  |     warnings.filterwarnings("ignore", "", DeprecationWarning, modname) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-22 23:37:04 +00:00
										 |  |  |     names = {} | 
					
						
							| 
									
										
										
										
											2001-01-25 15:29:22 +00:00
										 |  |  |     try: | 
					
						
							|  |  |  |         exec "import %s" % modname in names | 
					
						
							|  |  |  |     except ImportError: | 
					
						
							| 
									
										
										
										
											2001-02-12 03:27:31 +00:00
										 |  |  |         # Silent fail here seems the best route since some modules | 
					
						
							|  |  |  |         # may not be available in all environments. | 
					
						
							|  |  |  |         # Since an ImportError may leave a partial module object in | 
					
						
							|  |  |  |         # sys.modules, get rid of that first.  Here's what happens if | 
					
						
							|  |  |  |         # you don't:  importing pty fails on Windows because pty tries to | 
					
						
							|  |  |  |         # import FCNTL, which doesn't exist.  That raises an ImportError, | 
					
						
							|  |  |  |         # caught here.  It also leaves a partial pty module in sys.modules. | 
					
						
							|  |  |  |         # So when test_pty is called later, the import of pty succeeds, | 
					
						
							|  |  |  |         # but shouldn't.  As a result, test_pty crashes with an | 
					
						
							|  |  |  |         # AtttributeError instead of an ImportError, and regrtest interprets | 
					
						
							|  |  |  |         # the latter as a test failure (ImportError is treated as "test | 
					
						
							|  |  |  |         # skipped" -- which is what test_pty should say on Windows). | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             del sys.modules[modname] | 
					
						
							|  |  |  |         except KeyError: | 
					
						
							|  |  |  |             pass | 
					
						
							| 
									
										
										
										
											2001-01-25 15:29:22 +00:00
										 |  |  |         return | 
					
						
							| 
									
										
										
										
											2001-01-22 23:37:04 +00:00
										 |  |  |     verify(hasattr(sys.modules[modname], "__all__"), | 
					
						
							|  |  |  |            "%s has no __all__ attribute" % modname) | 
					
						
							|  |  |  |     names = {} | 
					
						
							|  |  |  |     exec "from %s import *" % modname in names | 
					
						
							| 
									
										
										
										
											2001-02-07 22:46:55 +00:00
										 |  |  |     if names.has_key("__builtins__"): | 
					
						
							|  |  |  |         del names["__builtins__"] | 
					
						
							| 
									
										
										
										
											2001-01-22 23:37:04 +00:00
										 |  |  |     keys = names.keys() | 
					
						
							|  |  |  |     keys.sort() | 
					
						
							|  |  |  |     all = list(sys.modules[modname].__all__) # in case it's a tuple | 
					
						
							| 
									
										
										
										
											2001-01-20 19:54:20 +00:00
										 |  |  |     all.sort() | 
					
						
							| 
									
										
										
										
											2001-01-22 23:37:04 +00:00
										 |  |  |     verify(keys==all, "%s != %s" % (keys, all)) | 
					
						
							| 
									
										
										
										
											2001-01-20 19:54:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | check_all("BaseHTTPServer") | 
					
						
							|  |  |  | check_all("CGIHTTPServer") | 
					
						
							|  |  |  | check_all("ConfigParser") | 
					
						
							|  |  |  | check_all("Cookie") | 
					
						
							|  |  |  | check_all("MimeWriter") | 
					
						
							|  |  |  | check_all("SimpleHTTPServer") | 
					
						
							|  |  |  | check_all("SocketServer") | 
					
						
							|  |  |  | check_all("StringIO") | 
					
						
							|  |  |  | check_all("UserString") | 
					
						
							|  |  |  | check_all("aifc") | 
					
						
							|  |  |  | check_all("atexit") | 
					
						
							|  |  |  | check_all("audiodev") | 
					
						
							|  |  |  | check_all("base64") | 
					
						
							|  |  |  | check_all("bdb") | 
					
						
							|  |  |  | check_all("binhex") | 
					
						
							|  |  |  | check_all("calendar") | 
					
						
							|  |  |  | check_all("cgi") | 
					
						
							|  |  |  | check_all("cmd") | 
					
						
							|  |  |  | check_all("code") | 
					
						
							|  |  |  | check_all("codecs") | 
					
						
							|  |  |  | check_all("codeop") | 
					
						
							|  |  |  | check_all("colorsys") | 
					
						
							|  |  |  | check_all("commands") | 
					
						
							|  |  |  | check_all("compileall") | 
					
						
							|  |  |  | check_all("copy") | 
					
						
							|  |  |  | check_all("copy_reg") | 
					
						
							| 
									
										
										
										
											2001-01-25 15:29:22 +00:00
										 |  |  | check_all("dbhash") | 
					
						
							| 
									
										
										
										
											2001-01-20 19:54:20 +00:00
										 |  |  | check_all("dircache") | 
					
						
							|  |  |  | check_all("dis") | 
					
						
							| 
									
										
										
										
											2001-01-20 23:34:12 +00:00
										 |  |  | check_all("doctest") | 
					
						
							|  |  |  | check_all("dospath") | 
					
						
							|  |  |  | check_all("filecmp") | 
					
						
							|  |  |  | check_all("fileinput") | 
					
						
							|  |  |  | check_all("fnmatch") | 
					
						
							|  |  |  | check_all("fpformat") | 
					
						
							|  |  |  | check_all("ftplib") | 
					
						
							|  |  |  | check_all("getopt") | 
					
						
							|  |  |  | check_all("getpass") | 
					
						
							| 
									
										
										
										
											2001-01-23 15:35:05 +00:00
										 |  |  | check_all("gettext") | 
					
						
							| 
									
										
										
										
											2001-01-20 23:34:12 +00:00
										 |  |  | check_all("glob") | 
					
						
							| 
									
										
										
										
											2001-01-24 04:13:02 +00:00
										 |  |  | check_all("gopherlib") | 
					
						
							| 
									
										
										
										
											2001-01-23 15:35:05 +00:00
										 |  |  | check_all("gzip") | 
					
						
							|  |  |  | check_all("htmllib") | 
					
						
							|  |  |  | check_all("httplib") | 
					
						
							|  |  |  | check_all("ihooks") | 
					
						
							|  |  |  | check_all("imaplib") | 
					
						
							| 
									
										
										
										
											2001-01-24 06:27:27 +00:00
										 |  |  | check_all("imghdr") | 
					
						
							|  |  |  | check_all("imputil") | 
					
						
							|  |  |  | check_all("keyword") | 
					
						
							|  |  |  | check_all("linecache") | 
					
						
							|  |  |  | check_all("locale") | 
					
						
							|  |  |  | check_all("macpath") | 
					
						
							|  |  |  | check_all("macurl2path") | 
					
						
							|  |  |  | check_all("mailbox") | 
					
						
							|  |  |  | check_all("mhlib") | 
					
						
							| 
									
										
										
										
											2001-01-25 15:29:22 +00:00
										 |  |  | check_all("mimetools") | 
					
						
							|  |  |  | check_all("mimetypes") | 
					
						
							|  |  |  | check_all("mimify") | 
					
						
							| 
									
										
										
										
											2001-02-06 01:07:02 +00:00
										 |  |  | check_all("multifile") | 
					
						
							|  |  |  | check_all("netrc") | 
					
						
							|  |  |  | check_all("nntplib") | 
					
						
							|  |  |  | check_all("ntpath") | 
					
						
							|  |  |  | check_all("os") | 
					
						
							| 
									
										
										
										
											2001-02-07 23:14:30 +00:00
										 |  |  | check_all("pdb") | 
					
						
							|  |  |  | check_all("pickle") | 
					
						
							|  |  |  | check_all("pipes") | 
					
						
							|  |  |  | check_all("popen2") | 
					
						
							| 
									
										
										
										
											2001-02-12 02:00:42 +00:00
										 |  |  | check_all("poplib") | 
					
						
							|  |  |  | check_all("posixpath") | 
					
						
							|  |  |  | check_all("pprint") | 
					
						
							|  |  |  | check_all("pre") | 
					
						
							|  |  |  | check_all("profile") | 
					
						
							|  |  |  | check_all("pstats") | 
					
						
							|  |  |  | check_all("pty") | 
					
						
							|  |  |  | check_all("py_compile") | 
					
						
							|  |  |  | check_all("pyclbr") | 
					
						
							|  |  |  | check_all("quopri") | 
					
						
							| 
									
										
										
										
											2001-02-15 22:15:14 +00:00
										 |  |  | check_all("random") | 
					
						
							|  |  |  | check_all("re") | 
					
						
							|  |  |  | check_all("reconvert") | 
					
						
							|  |  |  | check_all("regsub") | 
					
						
							|  |  |  | check_all("repr") | 
					
						
							|  |  |  | check_all("rexec") | 
					
						
							|  |  |  | check_all("rfc822") | 
					
						
							|  |  |  | check_all("rlcompleter") | 
					
						
							| 
									
										
										
										
											2001-01-20 19:54:20 +00:00
										 |  |  | check_all("robotparser") | 
					
						
							| 
									
										
										
										
											2001-02-15 22:15:14 +00:00
										 |  |  | check_all("sched") | 
					
						
							|  |  |  | check_all("sgmllib") | 
					
						
							|  |  |  | check_all("shelve") | 
					
						
							|  |  |  | check_all("shlex") | 
					
						
							|  |  |  | check_all("shutil") | 
					
						
							|  |  |  | check_all("smtpd") | 
					
						
							|  |  |  | check_all("smtplib") | 
					
						
							|  |  |  | check_all("sndhdr") | 
					
						
							|  |  |  | check_all("socket") | 
					
						
							|  |  |  | check_all("sre") | 
					
						
							|  |  |  | check_all("stat_cache") |