blob: 8927003275993175f55cd95d41b8d15b0a208f38 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
"""A nose plugin to run coverage.py"""
import logging
from nose.plugins import Plugin
from coverage.runners.plugin import CoverageTestWrapper, OPTIONS
log = logging.getLogger("nose.plugins.coverage")
class Coverage(Plugin):
"""The nose plugin to measure test coverage."""
score = 200
status = {}
config = opts = coverage = None
def help(self):
"""The help for the --with-coverage option."""
return "Measure test coverage using coverage.py."
def options(self, parser, env):
"""Add command-line options."""
super(Coverage, self).options(parser, env)
for opt in OPTIONS:
parser.add_option(opt)
def configure(self, options, config):
"""Configure plugin."""
try:
self.status.pop('active')
except KeyError:
pass
super(Coverage, self).configure(options, config)
self.config = config
self.status['active'] = True
self.opts = options
def begin(self):
"""Begin recording coverage information."""
log.debug("Coverage begin")
self.coverage = CoverageTestWrapper(self.opts)
self.coverage.start()
def report(self, stream):
"""Output code coverage report."""
log.debug("Coverage report")
stream.write("Processing Coverage...\n")
self.coverage.finish(stream)
|