forked from nitely/Spirit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·47 lines (32 loc) · 984 Bytes
/
runtests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
import os
import sys
import logging
import django
from django.test.runner import DiscoverRunner
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.project.settings.test'
def setup_celery():
try:
from celery import Celery
except ImportError:
return
app = Celery('test')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
def log_warnings():
logger = logging.getLogger('py.warnings')
handler = logging.StreamHandler()
logger.addHandler(handler)
def run_tests(reverse=False):
sys.stdout.write(
"\nRunning spirit test suite, using settings %(settings)r\n\n" %
{"settings": os.environ['DJANGO_SETTINGS_MODULE']})
return DiscoverRunner(reverse=reverse).run_tests([])
def start():
django.setup()
log_warnings()
setup_celery()
if run_tests() or run_tests(reverse=True):
sys.exit(1)
if __name__ == "__main__":
start()