def loadTests(self, namespace):
"""
Load L{csb.test.Case}s from the given CSB C{namespace}. If the namespace
ends with a wildcard, tests from sub-packages will be loaded as well.
If the namespace is '__main__' or '.', tests are loaded from __main__.
@param namespace: test module namespace, e.g. 'csb.test.cases.bio' will
load tests from '/csb/test/cases/bio/__init__.py'
@type namespace: str
@return: a C{unittest.TestSuite} ready for the test runner
@rtype: C{unittest.TestSuite}
"""
if namespace.strip() == '.*':
namespace = '__main__.*'
elif namespace.strip() == '.':
namespace = '__main__'
if namespace.endswith('.*'):
return self.loadAllTests(namespace[:-2])
else:
loader = unittest.TestLoader()
tests = loader.loadTestsFromName(namespace)
return unittest.TestSuite(self._filter(tests))
评论列表
文章目录