forked from django-oscar/django-oscar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·41 lines (33 loc) · 1.14 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
#!/usr/bin/env python
import sys
import logging
from tests.config import configure
logging.disable(logging.CRITICAL)
def run_tests(*test_args):
from django_nose import NoseTestSuiteRunner
test_runner = NoseTestSuiteRunner()
if not test_args:
test_args = ['tests']
num_failures = test_runner.run_tests(test_args)
if num_failures:
sys.exit(num_failures)
if __name__ == '__main__':
args = sys.argv[1:]
if not args:
import multiprocessing
try:
num_cores = multiprocessing.cpu_count()
except NotImplementedError:
num_cores = 4
args = ['-s', '-x', '--processes=%s' % num_cores]
else:
# Some args specified. Check to see if any nose options have been
# specified. If they have, then don't set any
has_options = any(map(lambda x: x.startswith('--'), args))
if not has_options:
args.extend(['-s', '-x', '--with-specplugin'])
else:
# Remove options as nose will pick these up from sys.argv
args = [arg for arg in args if not arg.startswith('-')]
configure()
run_tests(*args)