[CMF-checkins] CVS: CMF/CMFCore/tests/base - __init__.py:1.1.2.1 utils.py:1.1.2.1
Chris Withers
chrisw@nipltd.com
Tue, 12 Feb 2002 09:12:42 -0500
Update of /cvs-repository/CMF/CMFCore/tests/base
In directory cvs.zope.org:/tmp/cvs-serv10109/CMFCore/tests/base
Added Files:
Tag: ChrisW-refactor_tests-branch
__init__.py utils.py
Log Message:
Factored out the crap in test_all so adding new test modules is a lot easier.
=== Added File CMF/CMFCore/tests/base/__init__.py ===
"""
Generic stuff for unit testing the CMF.
"""
=== Added File CMF/CMFCore/tests/base/utils.py ===
from unittest import TestSuite
from sys import modules
def build_test_suite(package_name,module_names,required=1):
"""
Utlitity for building a test suite from a package name
and a list of modules.
If required is false, then ImportErrors will simply result
in that module's tests not being added to the returned
suite.
"""
suite = TestSuite()
try:
for name in module_names:
the_name = package_name+'.'+name
__import__(the_name,globals(),locals())
suite.addTest(modules[the_name].test_suite())
except ImportError:
if required:
raise
return suite