diff options
author | David Stanek <dstanek@dstanek.com> | 2010-05-21 23:40:04 -0400 |
---|---|---|
committer | David Stanek <dstanek@dstanek.com> | 2010-05-21 23:40:04 -0400 |
commit | b06c5c724b507a0059caf645c42991f83b86aec2 (patch) | |
tree | bbd0a67b2c23c1161de64e8a20102512f1fff3d7 /coverage/noseplugin.py | |
parent | 59d386b3d2551b7b09990a55cd3cb6581fe0c5f4 (diff) | |
download | python-coveragepy-git-b06c5c724b507a0059caf645c42991f83b86aec2.tar.gz |
cleaned up the code for the nose plugin
Diffstat (limited to 'coverage/noseplugin.py')
-rw-r--r-- | coverage/noseplugin.py | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/coverage/noseplugin.py b/coverage/noseplugin.py index b2bf9b5a..9e254ea1 100644 --- a/coverage/noseplugin.py +++ b/coverage/noseplugin.py @@ -1,67 +1,49 @@ import logging -import unittest, os from nose.plugins import Plugin -import sys from coverage.testplugin import CoverageTestWrapper, options as coverage_opts + log = logging.getLogger(__name__) class Coverage(Plugin): - """ - Activate a coverage report using Ned Batchelder's coverage module. - """ - - name = "coverage_new" + """Nose plugin for coverage reporting.""" + score = 1 status = {} - + def options(self, parser, env): - """ - Add options to command line. - """ - Plugin.options(self, parser, env) + """Add command-line options.""" + + super(Coverage, self).options(parser, env) for opt in coverage_opts: parser.add_option(opt) - + def configure(self, options, config): - """ - Configure plugin. - """ + """Configure plugin.""" + try: self.status.pop('active') except KeyError: pass - Plugin.configure(self, options, config) - if self.enabled: - try: - import coverage - except ImportError: - log.error("Coverage not available: " - "unable to import coverage module") - self.enabled = False - return - + + super(Coverage, self).configure(options, config) + self.config = config self.status['active'] = True self.options = options - + def begin(self): - """ - Begin recording coverage information. - """ + """Begin recording coverage information.""" + log.debug("Coverage begin") - # Load the runner and start it up self.coverage = CoverageTestWrapper(self.options) self.coverage.start() - + def report(self, stream): - """ - Output code coverage report. - """ + """Output code coverage report.""" + log.debug("Coverage report") stream.write("Processing Coverage...") - # finish up with coverage self.coverage.finish(stream) - |