test_examples.py 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. import glob
  3. import os.path as osp
  4. import subprocess
  5. import sys
  6. here = osp.abspath(osp.dirname(__file__))
  7. paths = [i for i in glob.glob(f'{here}/*') if osp.isdir(i)]
  8. services_dir = osp.abspath(osp.join(here, '../packages/services/examples'))
  9. paths += [i for i in glob.glob(f'{services_dir}/*')]
  10. def header(path):
  11. test_name = osp.basename(path)
  12. print('\n')
  13. print('*' * 40)
  14. print(f'Starting {test_name} test')
  15. print('*' * 40)
  16. count = 0
  17. for path in sorted(paths):
  18. if osp.basename(path) == 'node':
  19. header(path)
  20. runner = osp.join(path, 'main.py')
  21. subprocess.check_call([sys.executable, runner])
  22. count += 1
  23. continue
  24. if not osp.exists(osp.join(path, 'main.py')):
  25. continue
  26. count += 1
  27. header(path)
  28. runner = osp.join(here, 'example_check.py')
  29. subprocess.check_call([sys.executable, runner, path])
  30. print(f'\n\n{count} tests complete!')