forked from jazzband/django-simple-history
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·70 lines (59 loc) · 1.82 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import logging
from os.path import abspath, dirname, join
from shutil import rmtree
import sys
import django
from django.conf import settings
sys.path.insert(0, abspath(dirname(__file__)))
media_root = join(abspath(dirname(__file__)), 'test_files')
rmtree(media_root, ignore_errors=True)
installed_apps = [
'simple_history.tests',
'simple_history.tests.custom_user',
'simple_history.tests.external',
'simple_history.tests.migration_test_app',
'simple_history',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.admin',
]
DEFAULT_SETTINGS = dict(
AUTH_USER_MODEL='custom_user.CustomUser',
ROOT_URLCONF='simple_history.tests.urls',
MEDIA_ROOT=media_root,
STATIC_URL='/static/',
INSTALLED_APPS=installed_apps,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
},
MIDDLEWARE_CLASSES=[
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
],
TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
}],
)
def main():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
if hasattr(django, 'setup'):
django.setup()
try:
from django.test.runner import DiscoverRunner
except ImportError:
from django.test.simple import DjangoTestSuiteRunner
failures = DjangoTestSuiteRunner(failfast=False).run_tests(['tests'])
else:
failures = DiscoverRunner(failfast=False).run_tests(
['simple_history.tests'])
sys.exit(failures)
if __name__ == "__main__":
logging.basicConfig()
main()