1import os 2import unittest 3 4 5def load_tests(loader, standard_tests, pattern): 6 # top level directory cached on loader instance 7 this_dir = os.path.dirname(__file__) 8 pattern = pattern or "test_*.py" 9 # We are inside unittest.test, so the top-level is two notches up 10 top_level_dir = os.path.dirname(os.path.dirname(this_dir)) 11 package_tests = loader.discover(start_dir=this_dir, pattern=pattern, 12 top_level_dir=top_level_dir) 13 standard_tests.addTests(package_tests) 14 return standard_tests 15 16 17if __name__ == '__main__': 18 unittest.main() 19