-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntests.py
executable file
·61 lines (49 loc) · 1.31 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
#!/usr/bin/env python
# Django must be set up before we import our libraries and run our tests
import os
import sys
import django
from django.conf import settings
if os.environ.get('TEST_WITH_REDIS'):
CACHE = {
'BACKEND': 'django_redis.cache.RedisCache',
"LOCATION": 'redis://127.0.0.1:6379/1',
}
else:
CACHE = {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'localhost',
'OPTIONS': {
'MAX_ENTRIES': 2 ** 32,
},
}
settings.configure(
TESTING=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
},
},
CACHES={
'default': CACHE,
},
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
),
MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',),
BROKER_URL='memory://',
CELERY_RESULT_BACKEND='cache',
CELERY_CACHE_BACKEND='memory',
CELERY_ALWAYS_EAGER=True,
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
)
if django.VERSION[:2] >= (1, 7):
django.setup()
# Run tests
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=1)
failures = test_runner.run_tests(['queued_once.tests'])
if failures:
sys.exit(failures)