def collect_tests():
tests = []
for root, _, files in os.walk(TESTS_ROOT):
for f in files:
if TEST_MODULE_REGEX.match(f):
test_file = os.path.join(root, f)
module_name, _ = os.path.splitext(os.path.relpath(test_file, PROJECT_ROOT))
module_name = module_name.replace("/", ".")
module = __import__(module_name)
for namepart in module_name.split(".")[1:]:
module = getattr(module, namepart)
for test_class in unittest.findTestCases(module)._tests:
for test_function in test_class._tests:
test_full_name = ".".join([module_name, type(test_function).__name__, test_function._testMethodName])
tests.append((test_file, module_name, test_full_name))
return tests
评论列表
文章目录