summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-01-22 23:37:04 (GMT)
committerGuido van Rossum <guido@python.org>2001-01-22 23:37:04 (GMT)
commitd0f5e7001637062ee21446e986ec528bbf27c621 (patch)
tree32769483c4828b9322cee8ca820fd908954066f5 /Lib
parent763cb0aa44ab1d91dead8517127b2d1b79d32553 (diff)
downloadcpython-d0f5e7001637062ee21446e986ec528bbf27c621.zip
cpython-d0f5e7001637062ee21446e986ec528bbf27c621.tar.gz
cpython-d0f5e7001637062ee21446e986ec528bbf27c621.tar.bz2
- Use "exec ... in dict" to avoid having to walk on eggshells; locals
no don't have to start with underscore. - Add spaces after commas in argument lists. - Only test dbhash if bsddb can be imported. (Wonder if there are more like this?)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test___all__.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 4947a04..0b684ec 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -1,19 +1,19 @@
-from test_support import verify, verbose, TestFailed
+from test_support import verify, verbose
import sys
-def check_all(_modname):
- exec "import %s" % _modname
- verify(hasattr(sys.modules[_modname],"__all__"),
- "%s has no __all__ attribute" % _modname)
- exec "del %s" % _modname
- exec "from %s import *" % _modname
-
- _keys = locals().keys()
- _keys.remove("_modname")
- _keys.sort()
- all = list(sys.modules[_modname].__all__) # in case it's a tuple
+def check_all(modname):
+ names = {}
+ exec "import %s" % modname in names
+ verify(hasattr(sys.modules[modname], "__all__"),
+ "%s has no __all__ attribute" % modname)
+ names = {}
+ exec "from %s import *" % modname in names
+ del names["__builtins__"]
+ keys = names.keys()
+ keys.sort()
+ all = list(sys.modules[modname].__all__) # in case it's a tuple
all.sort()
- verify(_keys==all,"%s != %s" % (_keys,all))
+ verify(keys==all, "%s != %s" % (keys, all))
check_all("BaseHTTPServer")
check_all("Bastion")
@@ -48,7 +48,13 @@ check_all("commands")
check_all("compileall")
check_all("copy")
check_all("copy_reg")
-check_all("dbhash")
+try:
+ import bsddb
+except ImportError:
+ if verbose:
+ print "can't import bsddb, so skipping dbhash"
+else:
+ check_all("dbhash")
check_all("dircache")
check_all("dis")
check_all("doctest")