forked from dfunckt/django-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·47 lines (35 loc) · 976 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 sys
from os import environ
from os.path import abspath, dirname, join
import nose
def main():
project_dir = dirname(abspath(__file__))
# setup path
sys.path.insert(0, project_dir) # project dir
sys.path.insert(0, join(project_dir, 'tests')) # tests dir
environ['DJANGO_SETTINGS_MODULE'] = 'testapp.settings'
try:
# django >= 1.7
from django import setup
except ImportError:
pass
else:
setup()
# setup test env
from django.test.utils import setup_test_environment
setup_test_environment()
# setup db
from django.core.management import call_command, CommandError
options = {
'interactive': False,
'verbosity': 1,
}
try:
call_command('migrate', **options)
except CommandError: # Django < 1.7
call_command('syncdb', **options)
# run tests
return nose.main()
if __name__ == '__main__':
main()