This repository has been archived by the owner on Dec 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
59 lines (48 loc) · 1.55 KB
/
tests.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
import os
import sys
import django
def main():
"""
Standalone django model test with a 'memory-only-django-installation'.
You can play with a django model without a complete django app installation.
http://www.djangosnippets.org/snippets/1044/
"""
os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
from django.conf import global_settings
global_settings.SECRET_KEY = "snakeoil"
global_settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
'beproud', 'django', 'ssl', 'tests', 'templates'),)
global_settings.INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.flatpages',
'django.contrib.sites',
'beproud.django.ssl',
)
global_settings.SITE_ID = 1
global_settings.ROOT_URLCONF = 'beproud.django.ssl.tests.urls'
global_settings.DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
global_settings.SSL_URLS = (
'^/sslurl/',
)
global_settings.SSL_IGNORE_URLS = (
'^/static/',
)
if django.VERSION > (1, 7):
django.setup()
from django.test.utils import get_runner
test_runner = get_runner(global_settings)
if django.VERSION > (1, 6):
tests = ['beproud.django.ssl']
else:
tests = ['ssl']
test_runner = test_runner()
failures = test_runner.run_tests(tests)
sys.exit(failures)
if __name__ == '__main__':
main()