您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

run_tests.py 1022B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. import sys
  3. import os
  4. import logging
  5. from optparse import OptionParser
  6. from coverage import coverage
  7. import tests.config
  8. from django.test.simple import DjangoTestSuiteRunner
  9. logging.disable(logging.CRITICAL)
  10. def run_tests(*test_args):
  11. test_runner = DjangoTestSuiteRunner(verbosity=1)
  12. if not test_args:
  13. test_args = ['oscar']
  14. num_failures = test_runner.run_tests(test_args)
  15. if num_failures:
  16. sys.exit(num_failures)
  17. if __name__ == '__main__':
  18. parser = OptionParser()
  19. parser.add_option('-c', '--coverage', dest='use_coverage', default=False,
  20. action='store_true', help="Generate coverage report")
  21. (options, args) = parser.parse_args()
  22. if options.use_coverage:
  23. print 'Running tests with coverage'
  24. c = coverage(source=['oscar'])
  25. c.start()
  26. run_tests(*args)
  27. c.stop()
  28. print 'Generate HTML reports'
  29. c.html_report()
  30. else:
  31. print 'Running tests'
  32. run_tests(*args)