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 12:12:27 -0500
commit2094909df35db45ca7a409cc37f38d49c3191d2a (patch)
treea48f2660032c26b364fb034bc1459e7674346bba
parent181d71c7ae537299a74291e4671bd8b896bcd55d (diff)
downloadpython-coveragepy-git-2094909df35db45ca7a409cc37f38d49c3191d2a.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.py20
3 files changed, 31 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..a76fe3b9 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1199,3 +1199,23 @@ 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()
+ # The warning isn't the point of this test, but suppress it.
+ with pytest.warns(Warning) as warns:
+ cov.combine()
+ assert_coverage_warnings(warns, "No data was collected. (no-data-collected)")
+ cov.save()
+ self.assert_file_count(".coverage.*", 0)
+ self.assert_exists(".coverage")