Skip to content

Commit

Permalink
Merge 55f39b4 into 2857e9e
Browse files Browse the repository at this point in the history
  • Loading branch information
kurniliya committed May 23, 2014
2 parents 2857e9e + 55f39b4 commit 002b60c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
24 changes: 16 additions & 8 deletions nose2/plugins/coverage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Use this plugin to activate coverage report.
To install this plugin, you need to activate ``coverage-plugin`` with extra requires :
To install this plugin, you need to activate ``coverage-plugin``
with extra requirements :
::
Expand All @@ -17,7 +18,7 @@
Or with this lines in ``unittest.cfg`` :
::
[coverage]
always-on = True
Expand Down Expand Up @@ -46,7 +47,8 @@ def __init__(self):
'--coverage-report', action='append', default=[], metavar='TYPE',
choices=['term', 'term-missing', 'annotate', 'html', 'xml'],
dest='coverage_report',
help='Generate selected reports, available types: term, term-missing, annotate, html, xml (multi-allowed)'
help='Generate selected reports, available types:'
' term, term-missing, annotate, html, xml (multi-allowed)'
)
group.add_argument(
'--coverage-config', action='store', default='', metavar='FILE',
Expand All @@ -57,20 +59,26 @@ def __init__(self):
def handleArgs(self, event):
"""Get our options in order command line, config file, hard coded."""

self.covSource = event.args.coverage_source or self.conSource or ['.']
self.covReport = event.args.coverage_report or self.conReport or ['term']
self.covConfig = event.args.coverage_config or self.conConfig or '.coveragerc'
self.covSource = (event.args.coverage_source or
self.conSource or ['.'])
self.covReport = (event.args.coverage_report or
self.conReport or ['term'])
self.covConfig = (event.args.coverage_config or
self.conConfig or '.coveragerc')

def startTestRun(self, event):
"""Only called if active so start coverage."""
self.covController = None
try:
import cov_core
except:
print('Warning: you need to install [coverage-plugin] extra require to use this plugin')
print('Warning: you need to install [coverage-plugin] '
'extra requirements to use this plugin')
return

self.covController = cov_core.Central(self.covSource, self.covReport, self.covConfig)
self.covController = cov_core.Central(self.covSource,
self.covReport,
self.covConfig)
self.covController.start()

def afterSummaryReport(self, event):
Expand Down
12 changes: 10 additions & 2 deletions nose2/tests/functional/test_coverage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os.path

from nose2.tests._common import FunctionalTestCase


Expand All @@ -9,6 +11,12 @@ def test_run(self):
'--with-coverage',
'--coverage=lib/'
)
STATS = ' 8 5 38%'

stdout, stderr = proc.communicate()
self.assertTestRunOutputMatches(proc, stderr='lib/mod1 8 5 38%')
self.assertTestRunOutputMatches(proc, stderr='TOTAL 8 5 38%')
self.assertTestRunOutputMatches(
proc,
stderr=os.path.join('lib', 'mod1').replace('\\', r'\\') + STATS)
self.assertTestRunOutputMatches(
proc,
stderr='TOTAL ' + STATS)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
six>=1.1,<1.4
six>=1.1,<1.5
cov-core>=1.12

0 comments on commit 002b60c

Please sign in to comment.