forked from DjangoAdminHackers/django-linkcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
59 lines (52 loc) · 2.03 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
#!/usr/bin/env python
import sys
from os.path import abspath, dirname
import django
from django.conf import settings
if not settings.configured:
test_settings = {
'DATABASES': {'default': {'ENGINE': 'django.db.backends.sqlite3'}},
'STATIC_URL': '/static/',
'MEDIA_URL': '/media/',
'INSTALLED_APPS': [
'django.contrib.admin', 'django.contrib.auth',
'django.contrib.sessions', 'django.contrib.contenttypes',
'django.contrib.messages',
'linkcheck', 'linkcheck.tests.sampleapp',
],
'ROOT_URLCONF': "linkcheck.tests.urls",
'SITE_DOMAIN': "localhost",
'MIDDLEWARE': [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
],
'TEMPLATES': [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.static',
'django.template.context_processors.request',
],
},
}],
'DEFAULT_AUTO_FIELD': 'django.db.models.AutoField',
'SECRET_KEY': 'arandomstring',
'LINKCHECK_CONNECTION_ATTEMPT_TIMEOUT': 1,
}
settings.configure(**test_settings)
def runtests(*test_args):
from django.test.runner import DiscoverRunner
parent = dirname(abspath(__file__))
sys.path.insert(0, parent)
test_runner = DiscoverRunner(verbosity=1, interactive=True)
failures = test_runner.run_tests(test_args)
sys.exit(failures)
if __name__ == '__main__':
django.setup()
runtests(*sys.argv[1:])