summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-18 06:16:55 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-11-18 06:16:55 -0500
commit1649d6bd32f557ca3c2cfb773b603ed5e6b2bbd5 (patch)
tree4598c2252ea2b88637810c735c22105d177f51d4
parent26b680d3d4253258161f1a20d556fbf3f3622581 (diff)
downloadpython-coveragepy-git-1649d6bd32f557ca3c2cfb773b603ed5e6b2bbd5.tar.gz
fix: suffix=False will suppress the suffix even with multiprocessing. #989
-rw-r--r--CHANGES.rst5
-rw-r--r--coverage/control.py7
-rw-r--r--tests/test_api.py17
3 files changed, 28 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 1d9ec922..0c48b706 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -37,6 +37,10 @@ Unreleased
- API: The exceptions raised by Coverage.py have been specialized, to provide
finer-grained catching of exceptions by third-party code.
+- API: Using ``suffix=False`` when constructing a Coverage object with
+ multiprocessing wouldn't suppress the data file suffix (`issue 989`_). This
+ is now fixed.
+
- Debug: The `coverage debug data` command will now sniff out combinable data
files, and report on all of them.
@@ -44,6 +48,7 @@ Unreleased
time, and show all of them, though this was never documented. This no longer
works, to allow for command-line options in the future.
+.. _issue 989: https://github.com/nedbat/coveragepy/issues/989
.. _issue 1203: https://github.com/nedbat/coveragepy/issues/1203
diff --git a/coverage/control.py b/coverage/control.py
index ce8ce153..00836b3c 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -482,10 +482,15 @@ class Coverage:
)
suffix = self._data_suffix_specified
- if suffix or self.config.parallel:
+ if suffix:
if not isinstance(suffix, str):
# if data_suffix=True, use .machinename.pid.random
suffix = True
+ elif self.config.parallel:
+ if suffix is None:
+ suffix = True
+ elif not isinstance(suffix, str):
+ suffix = bool(suffix)
else:
suffix = None
diff --git a/tests/test_api.py b/tests/test_api.py
index 6b065709..ca0bd274 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1199,3 +1199,20 @@ class RelativePathTest(CoverageTest):
assert files == {'foo.py', 'bar.py', os_sep('modsrc/__init__.py')}
res = cov.report()
assert res == 100
+
+ def test_combine_no_suffix_multiprocessing(self):
+ self.make_file(".coveragerc", """\
+ [run]
+ branch = True
+ """)
+ cov = coverage.Coverage(
+ config_file=".coveragerc",
+ concurrency="multiprocessing",
+ data_suffix=False,
+ )
+ cov.start()
+ cov.stop()
+ cov.combine()
+ cov.save()
+ self.assert_file_count(".coverage.*", 0)
+ self.assert_exists(".coverage")