runtests.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. import base64
  3. import logging
  4. import os
  5. import sys
  6. from os.path import dirname, abspath
  7. from optparse import OptionParser
  8. sys.path.insert(0, dirname(abspath(__file__)))
  9. logging.getLogger('sentry').addHandler(logging.StreamHandler())
  10. from django.conf import settings
  11. if not settings.configured:
  12. os.environ['DJANGO_SETTINGS_MODULE'] = 'sentry.conf.server'
  13. # override a few things with our test specifics
  14. settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + (
  15. 'tests',
  16. )
  17. settings.SENTRY_KEY = base64.b64encode(os.urandom(40))
  18. settings.SENTRY_PUBLIC = False
  19. from django_nose import NoseTestSuiteRunner
  20. def runtests(*test_args, **kwargs):
  21. if 'south' in settings.INSTALLED_APPS:
  22. from south.management.commands import patch_for_test_db_setup
  23. patch_for_test_db_setup()
  24. if not test_args:
  25. test_args = ['tests']
  26. test_runner = NoseTestSuiteRunner(**kwargs)
  27. failures = test_runner.run_tests(test_args)
  28. sys.exit(failures)
  29. if __name__ == '__main__':
  30. parser = OptionParser()
  31. parser.add_option('--verbosity', dest='verbosity', action='store', default=1, type=int)
  32. parser.add_options(NoseTestSuiteRunner.options)
  33. (options, args) = parser.parse_args()
  34. runtests(*args, **options.__dict__)