forked from jneight/django-db-geventpool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
71 lines (62 loc) · 1.69 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
71
#!/usr/bin/env python
import sys
import gevent.monkey
gevent.monkey.patch_all()
try:
from psycopg2cffi import compat
compat.register()
except ImportError:
pass
import psycogreen.gevent
psycogreen.gevent.patch_psycopg()
import django
from django.conf import settings
if django.VERSION < (1,6):
settings.configure(
DEBUG=True,
DATABASES={
'default': {
'ENGINE': 'django_db_geventpool.backends.postgresql_psycopg2',
'NAME': 'test',
'USER': 'postgres',
'PASSWORD': 'postgres',
'OPTIONS': {'autocommit': True},
}
},
INSTALLED_APPS=(
'django_db_geventpool',
'tests',
),
USE_TZ=True,
)
else:
settings.configure(
DEBUG=True,
DATABASES={
'default': {
'ENGINE': 'django_db_geventpool.backends.postgresql_psycopg2',
'NAME': 'test',
'USER': 'postgres',
'PASSWORD': 'postgres',
'ATOMIC_REQUESTS': False,
'CONN_MAX_AGE': 0,
}
},
INSTALLED_APPS=(
'tests',
'django_db_geventpool',
),
USE_TZ=True,
)
try:
django.setup()
except AttributeError:
pass # not using django 1.7
try:
from django.test.runner import DiscoverRunner as TestSuiteRunner
except ImportError: # DiscoverRunner is the preferred one for django > 1.7
from django.test.simple import DjangoTestSuiteRunner as TestSuiteRunner
test_runner = TestSuiteRunner(verbosity=1)
failures = test_runner.run_tests(['tests', ])
if failures:
sys.exit(failures)