No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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)