summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-03-06 12:27:50 -0500
committerNed Batchelder <ned@nedbatchelder.com>2010-03-06 12:27:50 -0500
commitf80a6b08cbb593a0ec0419ac01e6826c7072376b (patch)
tree01591e7c45aa43b3a73bbbfc18044c5fc404904c
parentd7eecfcb48fe8b57d6051687b9e23523fef639e4 (diff)
downloadpython-coveragepy-git-f80a6b08cbb593a0ec0419ac01e6826c7072376b.tar.gz
Don't let parallel=True prevent reporting. Fixes #49.
-rw-r--r--CHANGES.txt6
-rw-r--r--coverage/control.py19
-rw-r--r--test/test_process.py15
3 files changed, 23 insertions, 17 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 4f6026ac..606600d5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,9 +5,13 @@ Change history for Coverage.py
Version 3.3.1
-------------
+- Using `parallel=True` in .coveragerc file prevented reporting, but now does
+ not, fixing `issue 49`.
+
- When running your code with "coverage run", if you call `sys.exit()`,
coverage.py will exit with that status code, fixing `issue 50`.
-
+
+.. _issue 49: http://bitbucket.org/ned/coveragepy/issue/49
.. _issue 50: http://bitbucket.org/ned/coveragepy/issue/50
diff --git a/coverage/control.py b/coverage/control.py
index b8b049e9..1456178a 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -105,9 +105,10 @@ class coverage(object):
)
else:
data_suffix = None
+ self.run_suffix = data_suffix
self.data = CoverageData(
- basename=self.config.data_file, suffix=data_suffix,
+ basename=self.config.data_file,
collector="coverage v%s" % __version__
)
@@ -190,6 +191,14 @@ class coverage(object):
def start(self):
"""Start measuring code coverage."""
+ if self.run_suffix:
+ # If the .coveragerc file specifies parallel=True, then we need to
+ # remake the data file for collection, with a suffix.
+ from coverage import __version__
+ self.data = CoverageData(
+ basename=self.config.data_file, suffix=self.run_suffix,
+ collector="coverage v%s" % __version__
+ )
if self.auto_data:
self.load()
# Save coverage data when Python exits.
@@ -251,14 +260,6 @@ class coverage(object):
current measurements.
"""
- # If the .coveragerc file specifies parallel=True, then self.data
- # already points to a suffixed data file. This won't be right for
- # combining, so make a new self.data with no suffix.
- from coverage import __version__
- self.data = CoverageData(
- basename=self.config.data_file,
- collector="coverage v%s" % __version__
- )
self.data.combine_parallel_data()
def _harvest_data(self):
diff --git a/test/test_process.py b/test/test_process.py
index fca79d48..ce98a383 100644
--- a/test/test_process.py
+++ b/test/test_process.py
@@ -1,6 +1,6 @@
"""Tests for process behavior of coverage.py."""
-import os, sys
+import os, sys, textwrap
import coverage
sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
@@ -120,12 +120,13 @@ class ProcessTest(CoverageTest):
data.read_file(".coverage")
self.assertEqual(data.summary()['b_or_c.py'], 7)
- # TODO
- ## Reporting should still work even with the .rc file
- #out = self.run_command("coverage report")
- #self.assertMultiLineEqual(out, """\
- # hello
- # """)
+ # Reporting should still work even with the .rc file
+ out = self.run_command("coverage report")
+ self.assertMultiLineEqual(out, textwrap.dedent("""\
+ Name Stmts Exec Cover
+ ----------------------------
+ b_or_c 7 7 100%
+ """))
def test_missing_source_file(self):
# Check what happens if the source is missing when reporting happens.