|
|
@@ -20,38 +20,26 @@ $ ./runtests.py tests/unit
|
|
20
|
20
|
Run all checkout unit tests (using spec output)
|
|
21
|
21
|
$ ./runtests.py tests/unit/checkout
|
|
22
|
22
|
|
|
23
|
|
-Run all tests relating to shipping
|
|
24
|
|
-$ ./runtests.py --attr=shipping
|
|
25
|
|
-
|
|
26
|
|
-Re-run failing tests (needs to be run twice to first build the index)
|
|
27
|
|
-$ ./runtests.py ... --failed
|
|
|
23
|
+Re-run failing tests (requires pytest-cache)
|
|
|
24
|
+$ ./runtests.py ... --lf
|
|
28
|
25
|
|
|
29
|
26
|
Drop into pdb when a test fails
|
|
30
|
|
-$ ./runtests.py ... --pdb-failures
|
|
|
27
|
+$ ./runtests.py ... --pdb
|
|
31
|
28
|
"""
|
|
32
|
29
|
|
|
33
|
30
|
import os
|
|
|
31
|
+import multiprocessing
|
|
34
|
32
|
import sys
|
|
35
|
33
|
import logging
|
|
36
|
34
|
import warnings
|
|
37
|
35
|
|
|
38
|
|
-import django
|
|
|
36
|
+import pytest
|
|
39
|
37
|
from django.utils.six.moves import map
|
|
40
|
38
|
|
|
41
|
39
|
# No logging
|
|
42
|
40
|
logging.disable(logging.CRITICAL)
|
|
43
|
41
|
|
|
44
|
42
|
|
|
45
|
|
-def run_tests(verbosity, *test_args):
|
|
46
|
|
- from django_nose import NoseTestSuiteRunner
|
|
47
|
|
- test_runner = NoseTestSuiteRunner(verbosity=verbosity)
|
|
48
|
|
- if not test_args:
|
|
49
|
|
- test_args = ['tests']
|
|
50
|
|
- num_failures = test_runner.run_tests(test_args)
|
|
51
|
|
- if num_failures:
|
|
52
|
|
- sys.exit(num_failures)
|
|
53
|
|
-
|
|
54
|
|
-
|
|
55
|
43
|
if __name__ == '__main__':
|
|
56
|
44
|
args = sys.argv[1:]
|
|
57
|
45
|
|
|
|
@@ -59,21 +47,26 @@ if __name__ == '__main__':
|
|
59
|
47
|
if not args:
|
|
60
|
48
|
# If run with no args, try and run the testsuite as fast as possible.
|
|
61
|
49
|
# That means across all cores and with no high-falutin' plugins.
|
|
62
|
|
- args = ['--nocapture', '--stop', '--processes=-1', 'tests']
|
|
|
50
|
+
|
|
|
51
|
+ try:
|
|
|
52
|
+ cpu_count = int(multiprocessing.cpu_count())
|
|
|
53
|
+ except ValueError:
|
|
|
54
|
+ cpu_count = 1
|
|
|
55
|
+
|
|
|
56
|
+ args = [
|
|
|
57
|
+ '--capture=no', '--nomigrations', '-n=%d' % cpu_count,
|
|
|
58
|
+ 'tests'
|
|
|
59
|
+ ]
|
|
63
|
60
|
else:
|
|
64
|
61
|
# Some args/options specified. Check to see if any nose options have
|
|
65
|
62
|
# been specified. If they have, then don't set any
|
|
66
|
63
|
has_options = any(map(lambda x: x.startswith('--'), args))
|
|
67
|
64
|
if not has_options:
|
|
68
|
65
|
# Default options:
|
|
69
|
|
- # --stop Abort on first error/failure
|
|
70
|
|
- # --nocapture Don't capture STDOUT
|
|
71
|
|
- args.extend(['--nocapture', '--stop'])
|
|
|
66
|
+ # --exitfirst Abort on first error/failure
|
|
|
67
|
+ # --capture=no Don't capture STDOUT
|
|
|
68
|
+ args.extend(['--capture=no', '--nomigrations', '--exitfirst'])
|
|
72
|
69
|
else:
|
|
73
|
|
- # Remove options as nose will pick these up from sys.argv
|
|
74
|
|
- for arg in args:
|
|
75
|
|
- if arg.startswith('--verbosity'):
|
|
76
|
|
- verbosity = int(arg[-1])
|
|
77
|
70
|
args = [arg for arg in args if not arg.startswith('-')]
|
|
78
|
71
|
|
|
79
|
72
|
with warnings.catch_warnings():
|
|
|
@@ -89,5 +82,4 @@ if __name__ == '__main__':
|
|
89
|
82
|
'ignore', r'.*', DeprecationWarning, libs)
|
|
90
|
83
|
|
|
91
|
84
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
|
|
92
|
|
- django.setup()
|
|
93
|
|
- run_tests(verbosity, *args)
|
|
|
85
|
+ pytest.main(args)
|