2014-11-20 22:43:38 +00:00
|
|
|
#!/usr/bin/env python
|
2014-11-04 10:24:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-11-20 22:43:38 +00:00
|
|
|
|
2014-11-04 10:24:58 +00:00
|
|
|
from __future__ import unicode_literals
|
2014-05-09 22:32:31 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2014-11-20 18:16:49 +00:00
|
|
|
import logging
|
2014-05-09 22:32:31 +00:00
|
|
|
|
2014-11-25 13:13:17 +00:00
|
|
|
EXAMPLE = 'example' in sys.argv
|
|
|
|
|
|
|
|
if EXAMPLE:
|
|
|
|
# Run tests with example settings
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings' # pragma: no cover
|
|
|
|
else:
|
|
|
|
# Run tests with tests settings
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
|
2014-05-09 22:32:31 +00:00
|
|
|
|
2014-09-29 01:22:00 +00:00
|
|
|
import django
|
2014-05-09 22:32:31 +00:00
|
|
|
from django.test.runner import DiscoverRunner
|
|
|
|
|
|
|
|
|
2014-11-20 18:16:49 +00:00
|
|
|
def log_warnings():
|
|
|
|
logger = logging.getLogger('py.warnings')
|
|
|
|
handler = logging.StreamHandler()
|
|
|
|
logger.addHandler(handler)
|
|
|
|
|
|
|
|
|
2014-05-09 22:32:31 +00:00
|
|
|
def run_tests():
|
2014-11-25 13:13:17 +00:00
|
|
|
sys.stdout.write(("\nRunning spirit test suite, using settings %(settings)r\n\n")
|
|
|
|
% {"settings": os.environ['DJANGO_SETTINGS_MODULE'], }
|
|
|
|
)
|
2014-05-09 22:32:31 +00:00
|
|
|
test_runner = DiscoverRunner()
|
2014-11-20 21:37:21 +00:00
|
|
|
failures = test_runner.run_tests(["tests", ])
|
2014-05-09 22:32:31 +00:00
|
|
|
sys.exit(failures)
|
|
|
|
|
|
|
|
|
2014-11-20 18:43:54 +00:00
|
|
|
def start():
|
2014-09-29 01:22:00 +00:00
|
|
|
django.setup()
|
2014-11-20 18:16:49 +00:00
|
|
|
log_warnings()
|
2014-11-17 11:55:59 +00:00
|
|
|
run_tests()
|
2014-11-20 18:43:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-11-20 20:09:59 +00:00
|
|
|
start()
|