summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Larson <larson.eric.d@gmail.com>2014-08-03 10:12:23 -0700
committerEric Larson <larson.eric.d@gmail.com>2016-01-27 14:35:40 -0500
commit822db03d54f5fe3b6064d582677d7b74474682f5 (patch)
tree3b2c06157315fcccd02583816f0229f472507991
parent344a215c8aa4c74f70ecaa70ed54c5158da59757 (diff)
downloadnose-822db03d54f5fe3b6064d582677d7b74474682f5.tar.gz
ENH: Allow not printing coverage report
-rw-r--r--CHANGELOG3
-rw-r--r--README.txt4
-rw-r--r--nose/plugins/cover.py35
3 files changed, 19 insertions, 23 deletions
diff --git a/CHANGELOG b/CHANGELOG
index fe2ed89..25d5090 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,8 @@
1.3.3
+- Add option to suppress printing of coverage report
+ Patch by Eric Larson.
- Fixed a minor issue with the reported version number.
1.3.2
@@ -883,4 +885,3 @@
- Increased compatibility with python 2.3 (and maybe earlier)
- Increased compatibility with tests written for py.test: now calls
module.setup_module(module) if module.setup_module() fails
-
diff --git a/README.txt b/README.txt
index 67b8f29..2047e4e 100644
--- a/README.txt
+++ b/README.txt
@@ -393,6 +393,10 @@ Options
Location of coverage config file [NOSE_COVER_CONFIG_FILE]
+--cover-no-print
+
+ Suppress printing of coverage information
+
--pdb
Drop into debugger on failures or errors
diff --git a/nose/plugins/cover.py b/nose/plugins/cover.py
index 0276f2d..0e8392a 100644
--- a/nose/plugins/cover.py
+++ b/nose/plugins/cover.py
@@ -29,6 +29,7 @@ class Coverage(Plugin):
coverInstance = None
coverErase = False
coverMinPercentage = None
+ coverNoPrint = False
score = 200
status = {}
@@ -85,7 +86,8 @@ class Coverage(Plugin):
dest="cover_xml",
help="Produce XML coverage information")
parser.add_option("--cover-xml-file", action="store",
- default=env.get('NOSE_COVER_XML_FILE', 'coverage.xml'),
+ default=env.get('NOSE_COVER_XML_FILE',
+ 'coverage.xml'),
dest="cover_xml_file",
metavar="FILE",
help="Produce XML coverage information in file")
@@ -94,6 +96,10 @@ class Coverage(Plugin):
dest="cover_config_file",
help="Location of coverage config file "
"[NOSE_COVER_CONFIG_FILE]")
+ parser.add_option("--cover-no-print", action="store_true",
+ default=env.get('NOSE_COVER_NO_PRINT'),
+ dest="cover_no_print",
+ help="Suppress printing of coverage information")
def configure(self, options, conf):
"""
@@ -140,10 +146,7 @@ class Coverage(Plugin):
if options.cover_xml:
self.coverXmlFile = options.cover_xml_file
log.debug('Will put XML coverage report in %s', self.coverXmlFile)
- # Coverage uses True to mean default
- self.coverConfigFile = True
- if options.cover_config_file:
- self.coverConfigFile = options.cover_config_file
+ self.coverNoPrint = options.cover_no_print
if self.enabled:
self.status['active'] = True
self.coverInstance = coverage.coverage(auto_data=False,
@@ -153,19 +156,7 @@ class Coverage(Plugin):
self.coverInstance.is_worker = conf.worker
self.coverInstance.exclude('#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]')
- log.debug("Coverage begin")
- self.skipModules = sys.modules.keys()[:]
- if self.coverErase:
- log.debug("Clearing previously collected coverage statistics")
- self.coverInstance.combine()
- self.coverInstance.erase()
-
- if not self.coverInstance.is_worker:
- self.coverInstance.load()
- self.coverInstance.start()
-
-
- def beforeTest(self, *args, **kwargs):
+ def begin(self):
"""
Begin recording coverage information.
"""
@@ -193,10 +184,11 @@ class Coverage(Plugin):
self.coverInstance.combine()
self.coverInstance.save()
modules = [module
- for name, module in sys.modules.items()
- if self.wantModuleCoverage(name, module)]
+ for name, module in sys.modules.items()
+ if self.wantModuleCoverage(name, module)]
log.debug("Coverage report will cover modules: %s", modules)
- self.coverInstance.report(modules, file=stream)
+ if not self.coverNoPrint:
+ self.coverInstance.report(modules, file=stream)
import coverage
if self.coverHtmlDir:
@@ -237,7 +229,6 @@ class Coverage(Plugin):
log.error("No total percentage was found in coverage output, "
"something went wrong.")
-
def wantModuleCoverage(self, name, module):
if not hasattr(module, '__file__'):
log.debug("no coverage of %s: no __file__", name)