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.

runtests.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. import sys
  3. import logging
  4. from tests.config import configure
  5. logging.disable(logging.CRITICAL)
  6. def run_tests(verbosity, *test_args):
  7. from django_nose import NoseTestSuiteRunner
  8. test_runner = NoseTestSuiteRunner(verbosity=verbosity)
  9. if not test_args:
  10. test_args = ['tests']
  11. num_failures = test_runner.run_tests(test_args)
  12. if num_failures:
  13. sys.exit(num_failures)
  14. if __name__ == '__main__':
  15. args = sys.argv[1:]
  16. verbosity = 1
  17. if not args:
  18. # If run with no args, try and run the testsuite as fast as possible.
  19. # That means across all cores and with no high-falutin' plugins.
  20. import multiprocessing
  21. try:
  22. num_cores = multiprocessing.cpu_count()
  23. except NotImplementedError:
  24. num_cores = 4 # Guess
  25. args = ['--nocapture', '--stop', '--processes=%s' % num_cores]
  26. else:
  27. # Some args/options specified. Check to see if any nose options have
  28. # been specified. If they have, then don't set any
  29. has_options = any(map(lambda x: x.startswith('--'), args))
  30. if not has_options:
  31. # Default options:
  32. # --stop Abort on first error/failure
  33. # --nocapture Don't capture STDOUT
  34. args.extend(['--nocapture', '--stop', '--with-specplugin'])
  35. else:
  36. # Remove options as nose will pick these up from sys.argv
  37. for arg in args:
  38. if arg.startswith('--verbosity'):
  39. verbosity = int(arg[-1])
  40. args = [arg for arg in args if not arg.startswith('-')]
  41. configure()
  42. run_tests(verbosity, *args)