Commits

Anonymous committed 2720b53

Finish and report in after summary report hook to use reporter stream.

Default source root of current dir.

Make command line arguments nose like.

Comments (0)

Files changed (3)

 
 The following will report on the combined coverage of the main process and all of it's subprocesses::
 
-    nose2 --with-cov --cov testfoo testfoo
+    nose2 --with-cov testfoo
 
 Shows a terminal report::
 
 
 The terminal report without line numbers (default)::
 
-    nose2 --with-cov --cov-report term --cov testfoo testfoo
+    nose2 --with-cov --cov-report term testfoo
 
     ---------- coverage: platform linux2, python 2.7.1-final-0 -----------
     Name      Stmts   Miss  Cover
 
 The terminal report with line numbers::
 
-    nose2 --with-cov --cov-report term-missing --cov testfoo testfoo
+    nose2 --with-cov --cov-report term-missing testfoo
 
     ---------- coverage: platform linux2, python 2.7.1-final-0 -----------
     Name      Stmts   Miss  Cover   Missing
 The remaining three reports output to files (useful for when the output is going to a continuous
 integration server)::
 
-    nose2 --with-cov --cov-report html --cov-report xml --cov-report annotate --cov testfoo testfoo
+    nose2 --with-cov --cov-report html --cov-report xml --cov-report annotate testfoo
 
 
 Coverage Data File
 """Coverage plugin for nose2."""
 
 import nose2
-import sys
 
 
 class CovPlugin(nose2.events.Plugin):
 
     configSection = 'cov'
-    commandLineSwitch = ('C', 'with-cov', 'Turn on coverage collection')
+    commandLineSwitch = ('C', 'with-cov', 'Turn on coverage reporting')
 
     def __init__(self):
-        """Get our config and add our options."""
+        """Get our config and add our command line arguments."""
 
         self.conSource = self.config.as_list('cov', [])
         self.conReport = self.config.as_list('cov-report', [])
         self.conConfig = self.config.as_str('cov-config', '').strip()
 
         group = self.session.pluginargs
-        group.add_argument('--cov', action='append', default=[], metavar='path',
+        group.add_argument('--cov', action='append', default=[], metavar='PATH',
                            dest='cov_source',
-                           help='measure coverage for filesystem path (multi-allowed)')
-        group.add_argument('--cov-report', action='append', default=[], metavar='type',
+                           help='Measure coverage for filesystem path (multi-allowed)')
+        group.add_argument('--cov-report', action='append', default=[], metavar='TYPE',
                            choices=['term', 'term-missing', 'annotate', 'html', 'xml'],
                            dest='cov_report',
-                           help='type of report to generate: term, term-missing, annotate, html, xml (multi-allowed)')
-        group.add_argument('--cov-config', action='store', default='', metavar='path',
+                           help='Generate selected reports, available types: term, term-missing, annotate, html, xml (multi-allowed)')
+        group.add_argument('--cov-config', action='store', default='', metavar='FILE',
                            dest='cov_config',
-                           help='config file for coverage, default: .coveragerc')
+                           help='Config file for coverage, default: .coveragerc')
 
     def handleArgs(self, event):
         """Get our options in order command line, config file, hard coded."""
 
-        self.covSource = event.args.cov_source or self.conSource
+        self.covSource = event.args.cov_source or self.conSource or ['.']
         self.covReport = event.args.cov_report or self.conReport or ['term']
         self.covConfig = event.args.cov_config or self.conConfig or '.coveragerc'
 
     def startTestRun(self, event):
-        """If we are enabled then start coverage."""
+        """Only called if active so start coverage."""
 
-        if self.covSource:
-            import cov_core
-            self.covController = cov_core.Central(self.covSource, self.covReport, self.covConfig)
-            self.covController.start()
+        import cov_core
+        self.covController = cov_core.Central(self.covSource, self.covReport, self.covConfig)
+        self.covController.start()
 
-    def stopTestRun(self, event):
-        """If we are enabled then produce coverage reports."""
+    def afterSummaryReport(self, event):
+        """Only called if active so stop coverage and produce reports."""
 
-        if self.covSource:
-            stream = nose2.util._WritelnDecorator(sys.stderr)
-            self.covController.finish()
-            self.covController.summary(stream)
+        self.covController.finish()
+        self.covController.summary(event.stream)
 import setuptools
 
 setuptools.setup(name='nose2-cov',
-                 version='1.0a2',
+                 version='1.0a3',
                  description='nose2 plugin for coverage reporting, including subprocesses',
                  long_description=open('README.txt').read().strip(),
                  author='Meme Dough',