def make_test_program_class(extra_tests):
"""
Return a subclass of unittest.TestProgram.
"""
# The function unittest.main() is an alias for unittest.TestProgram's
# constructor. TestProgram's constructor does the following:
#
# 1. calls self.parseArgs(argv),
# 2. which in turn calls self.createTests().
# 3. then the constructor calls self.runTests().
#
# The createTests() method sets the self.test attribute by calling one
# of self.testLoader's "loadTests" methods. Each loadTest method returns
# a unittest.TestSuite instance. Thus, self.test is set to a TestSuite
# instance prior to calling runTests().
class PystacheTestProgram(TestProgram):
"""
Instantiating an instance of this class runs all tests.
"""
def createTests(self):
"""
Load tests and set self.test to a unittest.TestSuite instance
Compare--
http://docs.python.org/library/unittest.html#unittest.TestSuite
"""
super(PystacheTestProgram, self).createTests()
self.test.addTests(extra_tests)
return PystacheTestProgram
# Do not include "test" in this function's name to avoid it getting
# picked up by nosetests.
评论列表
文章目录