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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  2. import sys
  3. import logging
  4. from optparse import OptionParser
  5. from coverage import coverage
  6. from tests.config import configure
  7. logging.disable(logging.CRITICAL)
  8. def run_tests(options, *test_args):
  9. from django_nose import NoseTestSuiteRunner
  10. test_runner = NoseTestSuiteRunner(verbosity=options.verbosity,
  11. pdb=options.pdb,
  12. )
  13. if not test_args:
  14. test_args = ['tests']
  15. num_failures = test_runner.run_tests(test_args)
  16. if num_failures:
  17. sys.exit(num_failures)
  18. if __name__ == '__main__':
  19. parser = OptionParser()
  20. parser.add_option('-c', '--coverage', dest='use_coverage', default=False,
  21. action='store_true', help="Generate coverage report")
  22. parser.add_option('-v', '--verbosity', dest='verbosity', default=1,
  23. type='int', help="Verbosity of output")
  24. parser.add_option('-d', '--pdb', dest='pdb', default=False,
  25. action='store_true', help="Whether to drop into PDB on failure/error")
  26. (options, args) = parser.parse_args()
  27. # If no args, then use 'progressive' plugin to keep the screen real estate
  28. # used down to a minimum. Otherwise, use the spec plugin
  29. nose_args = ['-s', '-x',
  30. '--with-progressive' if not args else '--with-spec']
  31. configure(nose_args)
  32. if options.use_coverage:
  33. print 'Running tests with coverage'
  34. c = coverage(source=['oscar'])
  35. c.start()
  36. run_tests(options, *args)
  37. c.stop()
  38. print 'Generate HTML reports'
  39. c.html_report()
  40. else:
  41. run_tests(options, *args)