|
|
@@ -3,6 +3,7 @@ import sys
|
|
3
|
3
|
import os
|
|
4
|
4
|
import logging
|
|
5
|
5
|
from optparse import OptionParser
|
|
|
6
|
+from coverage import coverage
|
|
6
|
7
|
|
|
7
|
8
|
import tests.config
|
|
8
|
9
|
|
|
|
@@ -15,10 +16,24 @@ def run_tests(*test_args):
|
|
15
|
16
|
test_runner = DjangoTestSuiteRunner(verbosity=1)
|
|
16
|
17
|
if not test_args:
|
|
17
|
18
|
test_args = ['oscar']
|
|
18
|
|
- failures = test_runner.run_tests(test_args)
|
|
19
|
|
- sys.exit(failures)
|
|
|
19
|
+ num_failures = test_runner.run_tests(test_args)
|
|
|
20
|
+ if num_failures:
|
|
|
21
|
+ sys.exit(num_failures)
|
|
20
|
22
|
|
|
21
|
23
|
if __name__ == '__main__':
|
|
22
|
24
|
parser = OptionParser()
|
|
|
25
|
+ parser.add_option('-c', '--coverage', dest='use_coverage', default=False,
|
|
|
26
|
+ action='store_true', help="Generate coverage report")
|
|
23
|
27
|
(options, args) = parser.parse_args()
|
|
24
|
|
- run_tests(*args)
|
|
|
28
|
+
|
|
|
29
|
+ if options.use_coverage:
|
|
|
30
|
+ print 'Running tests with coverage'
|
|
|
31
|
+ c = coverage(source=['oscar'])
|
|
|
32
|
+ c.start()
|
|
|
33
|
+ run_tests(*args)
|
|
|
34
|
+ c.stop()
|
|
|
35
|
+ print 'Generate HTML reports'
|
|
|
36
|
+ c.html_report()
|
|
|
37
|
+ else:
|
|
|
38
|
+ print 'Running tests'
|
|
|
39
|
+ run_tests(*args)
|