run_tests.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:pysimgrid 作者: alexmnazarenko 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号