forked from django-extensions/django-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·59 lines (51 loc) · 1.93 KB
/
run_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
#!/usr/bin/env python
import sys
import shutil
import tempfile
from django.conf import settings
def main():
# Dynamically configure the Django settings with the minimum necessary to
# get Django running tests
ENCRYPTED_FIELD_KEYS_DIR = None
try:
try:
from keyczar import keyczart, keyinfo
ENCRYPTED_FIELD_KEYS_DIR = tempfile.mkdtemp("django_extensions_tests_keyzcar_keys_dir")
# TODO: move this to the unit test for encrypted fields
keyczart.Create(ENCRYPTED_FIELD_KEYS_DIR, "test", keyinfo.DECRYPT_AND_ENCRYPT)
keyczart.AddKey(ENCRYPTED_FIELD_KEYS_DIR, "PRIMARY")
except ImportError:
pass
settings.configure(
INSTALLED_APPS=[
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.sessions',
'django_extensions',
'django_extensions.tests',
],
# Django replaces this, but it still wants it. *shrugs*
DATABASE_ENGINE='django.db.backends.sqlite3',
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
},
MEDIA_ROOT='/tmp/django_extensions_test_media/',
MEDIA_PATH='/media/',
ROOT_URLCONF='django_extensions.tests.urls',
DEBUG=True,
TEMPLATE_DEBUG=True,
ENCRYPTED_FIELD_KEYS_DIR=ENCRYPTED_FIELD_KEYS_DIR,
)
from django.test.utils import get_runner
test_runner = get_runner(settings)(verbosity=2, interactive=True)
failures = test_runner.run_tests(['django_extensions'])
sys.exit(failures)
finally:
if ENCRYPTED_FIELD_KEYS_DIR:
# cleanup crypto key temp dir
shutil.rmtree(ENCRYPTED_FIELD_KEYS_DIR)
if __name__ == '__main__':
main()