added a few more __all__ lists

test___all__.py: fail silently in check_all if the module can't be imported
This commit is contained in:
Skip Montanaro 2001-01-25 15:29:22 +00:00
parent 438bb94789
commit 03d9014992
4 changed files with 16 additions and 8 deletions

View File

@ -5,6 +5,8 @@ import os
import rfc822 import rfc822
import tempfile import tempfile
__all__ = ["Message","choose_boundary","encode","decode","copyliteral",
"copybinary"]
class Message(rfc822.Message): class Message(rfc822.Message):
"""A derived class of rfc822.Message that knows about MIME headers and """A derived class of rfc822.Message that knows about MIME headers and

View File

@ -27,6 +27,8 @@ import string
import posixpath import posixpath
import urllib import urllib
__all__ = ["guess_type","guess_extension","read_mime_types","init"]
knownfiles = [ knownfiles = [
"/usr/local/etc/httpd/conf/mime.types", "/usr/local/etc/httpd/conf/mime.types",
"/usr/local/lib/netscape/mime.types", "/usr/local/lib/netscape/mime.types",

View File

@ -29,6 +29,8 @@ QUOTE = '> ' # string replies are quoted with
import re, string import re, string
__all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"]
qp = re.compile('^content-transfer-encoding:\\s*quoted-printable', re.I) qp = re.compile('^content-transfer-encoding:\\s*quoted-printable', re.I)
base64_re = re.compile('^content-transfer-encoding:\\s*base64', re.I) base64_re = re.compile('^content-transfer-encoding:\\s*base64', re.I)
mp = re.compile('^content-type:.*multipart/.*boundary="?([^;"\n]*)', re.I|re.S) mp = re.compile('^content-type:.*multipart/.*boundary="?([^;"\n]*)', re.I|re.S)

View File

@ -3,7 +3,12 @@ import sys
def check_all(modname): def check_all(modname):
names = {} names = {}
try:
exec "import %s" % modname in names exec "import %s" % modname in names
except ImportError:
# silent fail here seems the best route since some modules
# may not be available in all environments
return
verify(hasattr(sys.modules[modname], "__all__"), verify(hasattr(sys.modules[modname], "__all__"),
"%s has no __all__ attribute" % modname) "%s has no __all__ attribute" % modname)
names = {} names = {}
@ -48,13 +53,7 @@ check_all("commands")
check_all("compileall") check_all("compileall")
check_all("copy") check_all("copy")
check_all("copy_reg") check_all("copy_reg")
try: check_all("dbhash")
import bsddb
except ImportError:
if verbose:
print "can't import bsddb, so skipping dbhash"
else:
check_all("dbhash")
check_all("dircache") check_all("dircache")
check_all("dis") check_all("dis")
check_all("doctest") check_all("doctest")
@ -85,4 +84,7 @@ check_all("macpath")
check_all("macurl2path") check_all("macurl2path")
check_all("mailbox") check_all("mailbox")
check_all("mhlib") check_all("mhlib")
check_all("mimetools")
check_all("mimetypes")
check_all("mimify")
check_all("robotparser") check_all("robotparser")