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 tests.config import configure
  6. logging.disable(logging.CRITICAL)
  7. def run_tests(*test_args):
  8. from django_nose import NoseTestSuiteRunner
  9. test_runner = NoseTestSuiteRunner()
  10. if not test_args:
  11. test_args = ['tests']
  12. num_failures = test_runner.run_tests(test_args)
  13. if num_failures:
  14. sys.exit(num_failures)
  15. if __name__ == '__main__':
  16. parser = OptionParser()
  17. parser.add_option('--with-coverage', dest='coverage', default=False,
  18. action='store_true')
  19. parser.add_option('--with-xunit', dest='xunit', default=False,
  20. action='store_true')
  21. parser.add_option('--collect-only', dest='collect', default=False,
  22. action='store_true')
  23. options, args = parser.parse_args()
  24. if options.collect:
  25. # Show tests only so a bash autocompleter can use the results
  26. configure(['-v'])
  27. run_tests()
  28. else:
  29. # If no args, then use 'progressive' plugin to keep the screen real estate
  30. # used down to a minimum. Otherwise, use the spec plugin
  31. nose_args = ['-s', '-x',
  32. '--with-progressive' if not args else '--with-spec']
  33. if options.coverage:
  34. # Nose automatically uses any options passed to runtests.py, which is
  35. # why the coverage trigger uses '--with-coverage' and why we don't need
  36. # to explicitly include it here.
  37. nose_args.extend([
  38. '--cover-package=oscar', '--cover-html',
  39. '--cover-html-dir=htmlcov'])
  40. configure(nose_args)
  41. run_tests(*args)