runtests.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. import sys
  3. import os
  4. import shutil
  5. import warnings
  6. from django.core.management import execute_from_command_line
  7. os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings'
  8. def runtests():
  9. # Don't ignore DeprecationWarnings
  10. warnings.simplefilter('default', DeprecationWarning)
  11. warnings.simplefilter('default', PendingDeprecationWarning)
  12. args = sys.argv[1:]
  13. if '--postgres' in args:
  14. os.environ['DATABASE_ENGINE'] = 'django.db.backends.postgresql_psycopg2'
  15. args.remove('--postgres')
  16. if '--elasticsearch' in args:
  17. os.environ.setdefault('ELASTICSEARCH_URL', 'http://localhost:9200')
  18. args.remove('--elasticsearch')
  19. argv = sys.argv[:1] + ['test'] + args
  20. try:
  21. execute_from_command_line(argv)
  22. finally:
  23. from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT
  24. shutil.rmtree(STATIC_ROOT, ignore_errors=True)
  25. shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
  26. if __name__ == '__main__':
  27. runtests()