[Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.3,1.4
Guido van Rossum
gvanrossum@users.sourceforge.net
Mon, 22 Jan 2001 15:37:06 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30198
Modified Files:
test___all__.py
Log Message:
- 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?)
Index: test___all__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** test___all__.py 2001/01/21 04:49:16 1.3
--- test___all__.py 2001/01/22 23:37:04 1.4
***************
*** 1,18 ****
! from test_support import verify, verbose, TestFailed
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
all.sort()
! verify(_keys==all,"%s != %s" % (_keys,all))
check_all("BaseHTTPServer")
--- 1,18 ----
! from test_support import verify, verbose
import sys
! 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))
check_all("BaseHTTPServer")
***************
*** 49,53 ****
check_all("copy")
check_all("copy_reg")
! check_all("dbhash")
check_all("dircache")
check_all("dis")
--- 49,59 ----
check_all("copy")
check_all("copy_reg")
! 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")