[Zodb-checkins] CVS: StandaloneZODB - test.py:1.1
Jeremy Hylton
jeremy@zope.com
Tue, 7 Aug 2001 18:33:38 -0400
Update of /cvs-repository/StandaloneZODB
In directory cvs.zope.org:/tmp/cvs-serv12003
Added Files:
test.py
Log Message:
Transitional script to run all available unit tests out of the build directory.
=== Added File StandaloneZODB/test.py ===
import os
import sys
import unittest
from distutils.util import get_platform
# setup list of directories to put on the path
PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3])
DIRS = ["lib",
"lib.%s" % PLAT_SPEC,
"../ExtensionClass/build/lib.%s" % PLAT_SPEC,
]
for d in DIRS:
sys.path.insert(0, d)
# find test files
class TestFileFinder:
def __init__(self):
self.files = []
def visit(self, arg, dir, files):
if dir.startswith("./build"):
return
if not dir.endswith("tests"):
return
# XXX special case bsddb3Storage
if dir.startswith("./bsddb3Storage/bsddb3Storage"):
dir = "./" + dir[16:]
for file in files:
if file.startswith("test") and file.endswith(".py"):
path = os.path.join(dir, file)
self.files.append(path)
finder = TestFileFinder()
os.path.walk(".", finder.visit, None)
def package_import(modname):
mod = __import__(modname)
for part in modname.split(".")[1:]:
mod = getattr(mod, part)
return mod
os.chdir("build")
alltests = unittest.TestSuite()
runner = unittest.TextTestRunner()
for file in finder.files:
assert file.startswith('./')
assert file.endswith('.py')
modname = file[2:-3]
modname = modname.replace(os.sep, '.')
mod = package_import(modname)
try:
suite = mod.test_suite()
except AttributeError:
continue
print modname
runner.run(suite)