Kaynağa Gözat

Rework test runner to generate coverage stats correctly.

Nose seems to pick up argv automatically - which is annoying.  Will need
to look into at some point.
master
David Winterbottom 13 yıl önce
ebeveyn
işleme
f1fcce8f0c
1 değiştirilmiş dosya ile 7 ekleme ve 23 silme
  1. 7
    23
      runtests.py

+ 7
- 23
runtests.py Dosyayı Görüntüle

@@ -2,18 +2,15 @@
2 2
 import sys
3 3
 import logging
4 4
 from optparse import OptionParser
5
-from coverage import coverage
6 5
 
7 6
 from tests.config import configure
8 7
 
9 8
 logging.disable(logging.CRITICAL)
10 9
 
11 10
 
12
-def run_tests(options, *test_args):
11
+def run_tests(*test_args):
13 12
     from django_nose import NoseTestSuiteRunner
14
-    test_runner = NoseTestSuiteRunner(verbosity=options.verbosity,
15
-                                      pdb=options.pdb,
16
-                                      )
13
+    test_runner = NoseTestSuiteRunner()
17 14
     if not test_args:
18 15
         test_args = ['tests']
19 16
     num_failures = test_runner.run_tests(test_args)
@@ -23,27 +20,14 @@ def run_tests(options, *test_args):
23 20
 
24 21
 if __name__ == '__main__':
25 22
     parser = OptionParser()
26
-    parser.add_option('-c', '--coverage', dest='use_coverage', default=False,
27
-                      action='store_true', help="Generate coverage report")
28
-    parser.add_option('-v', '--verbosity', dest='verbosity', default=1,
29
-                      type='int', help="Verbosity of output")
30
-    parser.add_option('-d', '--pdb', dest='pdb', default=False,
31
-                      action='store_true', help="Whether to drop into PDB on failure/error")
32
-    (options, args) = parser.parse_args()
23
+    __, args = parser.parse_args()
33 24
 
34 25
     # If no args, then use 'progressive' plugin to keep the screen real estate
35 26
     # used down to a minimum.  Otherwise, use the spec plugin
36 27
     nose_args = ['-s', '-x',
37 28
                  '--with-progressive' if not args else '--with-spec']
29
+    nose_args.extend([
30
+        '--with-coverage', '--cover-package=oscar', '--cover-html',
31
+        '--cover-html-dir=htmlcov'])
38 32
     configure(nose_args)
39
-
40
-    if options.use_coverage:
41
-        print 'Running tests with coverage'
42
-        c = coverage(source=['oscar'])
43
-        c.start()
44
-        run_tests(options, *args)
45
-        c.stop()
46
-        print 'Generate HTML reports'
47
-        c.html_report()
48
-    else:
49
-        run_tests(options, *args)
33
+    run_tests(*args)

Loading…
İptal
Kaydet