説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

nocontext_tests.py 963B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #-*- coding: utf-8 -*-
  2. # @brief Loader for tests which do not need an lodel installation
  3. #
  4. # Options
  5. ################
  6. #
  7. # @note We can pass the path to a directory to write results file, nocontext_tests.log
  8. # It has to be at first, otherwise it will not be taken
  9. # and the default one, current directory, will be used.
  10. # The results are not displayed, only stored in nocontext_tests.log
  11. #
  12. # -f, --failfast
  13. #
  14. # Stop the test run on the first error or failure.
  15. # -v --verbose
  16. #
  17. # higher verbosity
  18. #
  19. #
  20. import sys
  21. import os
  22. import os.path
  23. import unittest
  24. loader = unittest.TestLoader()
  25. if ((len(sys.argv) > 1) and (sys.argv[1].startswith('-')) is False):
  26. dpath = sys.argv[1]
  27. else:
  28. dpath = '.'
  29. suite = loader.discover('tests', pattern='nc_test*.py')
  30. with open(dpath + '/nocontext_tests.log', 'w') as logfile:
  31. unittest.TextTestRunner(
  32. logfile,
  33. failfast='-f' in sys.argv,
  34. verbosity=2 if '-v' in sys.argv else 1).run(suite)