1import os 2import sys 3import unittest 4 5 6here = os.path.dirname(__file__) 7loader = unittest.defaultTestLoader 8 9def suite(): 10 suite = unittest.TestSuite() 11 for fn in os.listdir(here): 12 if fn.startswith("test") and fn.endswith(".py"): 13 modname = "unittest.test." + fn[:-3] 14 __import__(modname) 15 module = sys.modules[modname] 16 suite.addTest(loader.loadTestsFromModule(module)) 17 suite.addTest(loader.loadTestsFromName('unittest.test.testmock')) 18 return suite 19 20 21if __name__ == "__main__": 22 unittest.main(defaultTest="suite") 23