run_all.py 647 B

123456789101112131415161718192021222324
  1. import os
  2. import subprocess
  3. from os import path
  4. here_dir = path.dirname(path.abspath(__file__))
  5. def run_all_test():
  6. """顺序运行所有测试用例"""
  7. files = [f for f in os.listdir(here_dir) if path.isfile(f) and f.split('.', 1)[0].isdigit()]
  8. files.sort(key=lambda f: int(f.split('.', 1)[0]))
  9. for f in files:
  10. file = path.join(here_dir, f)
  11. print("Run test script: %s" % file)
  12. res = subprocess.run(['python3', file, 'auto'], text=True, shell=True)
  13. if res.stdout:
  14. print(res.stdout)
  15. if res.stderr:
  16. print(res.stderr)
  17. if __name__ == '__main__':
  18. run_all_test()