Commits

David Stanek committed ec30ef3

cleaned up the code for the nose plugin

Comments (0)

Files changed (2)

coverage/noseplugin.py

 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)
-

test/test_testplugin.py

 from coverage.noseplugin import Coverage
 
 class TestCoverage(PluginTester, unittest.TestCase):
-    activate = '--with-coverage_new' # enables the plugin
+    activate = '--with-coverage' # enables the plugin
     plugins = [Coverage()]
     args = ['--cover-action=report']
-   
+
     @py.test.mark.skipif(True) # "requires nose test runner"
     def test_output(self):
         assert "Processing Coverage..." in self.output, (