-
Notifications
You must be signed in to change notification settings - Fork 5
/
runtests.py
36 lines (27 loc) · 997 Bytes
/
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
#!/usr/bin/env python
import sys
from os import environ, path
import django
import py
from django.conf import settings
# Give feedback on used versions
sys.stderr.write('Using Python version {0} from {1}\n'.format(sys.version[:5], sys.executable))
sys.stderr.write('Using Django version {0} from {1}\n'.format(
django.get_version(),
path.dirname(path.abspath(django.__file__)))
)
if not settings.configured:
module_root = path.dirname(path.realpath(__file__))
sys.path.insert(0, path.join(module_root, 'tests'))
sys.path.insert(0, module_root)
environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
DEFAULT_TEST_APPS = [
'tests',
]
def runtests():
other_args = list(filter(lambda arg: arg.startswith('-'), sys.argv[1:]))
test_apps = list(filter(lambda arg: not arg.startswith('-'), sys.argv[1:])) or DEFAULT_TEST_APPS
argv = sys.argv[:1] + other_args + test_apps
sys.exit(py.test.cmdline.main(argv))
if __name__ == '__main__':
runtests()