import os
import unittest
class TestLoader(unittest.TestLoader):
"""Test loader that extends unittest.TestLoader to:
* support names that can be a combination of modules and directories
"""
def loadTestsFromNames(self, names, module=None):
"""Return a suite of all tests cases found using the given sequence
of string specifiers. See 'loadTestsFromName()'.
"""
suites = []
for name in names:
if os.path.isdir(name):
top_level = os.path.split(name)[0]
suites.extend(self.discover(name, top_level_dir=top_level))
else:
suites.extend(self.loadTestsFromName(name, module))
return self.suiteClass(suites)
Then it just became a matter of borrowing from the subunit runner script and instantiating SubunitTestProgram with the new loader.
SubunitTestProgram(module=None, argv=sys.argv, testRunner=SubunitTestRunner,
stdout=sys.stdout, testLoader=TestLoader())
No comments:
Post a Comment