Skip to content

Commit 1649d6b

Browse files
committed
fix: suffix=False will suppress the suffix even with multiprocessing. #989
1 parent 26b680d commit 1649d6b

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGES.rst

+5
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ Unreleased
3737
- API: The exceptions raised by Coverage.py have been specialized, to provide
3838
finer-grained catching of exceptions by third-party code.
3939

40+
- API: Using ``suffix=False`` when constructing a Coverage object with
41+
multiprocessing wouldn't suppress the data file suffix (`issue 989`_). This
42+
is now fixed.
43+
4044
- Debug: The `coverage debug data` command will now sniff out combinable data
4145
files, and report on all of them.
4246

4347
- Debug: The `coverage debug` command used to accept a number of topics at a
4448
time, and show all of them, though this was never documented. This no longer
4549
works, to allow for command-line options in the future.
4650

51+
.. _issue 989: https://github.com/nedbat/coveragepy/issues/989
4752
.. _issue 1203: https://github.com/nedbat/coveragepy/issues/1203
4853

4954

coverage/control.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,15 @@ def _init_for_start(self):
482482
)
483483

484484
suffix = self._data_suffix_specified
485-
if suffix or self.config.parallel:
485+
if suffix:
486486
if not isinstance(suffix, str):
487487
# if data_suffix=True, use .machinename.pid.random
488488
suffix = True
489+
elif self.config.parallel:
490+
if suffix is None:
491+
suffix = True
492+
elif not isinstance(suffix, str):
493+
suffix = bool(suffix)
489494
else:
490495
suffix = None
491496

tests/test_api.py

+17
Original file line numberDiff line numberDiff line change
@@ -1199,3 +1199,20 @@ def test_combine_relative(self):
11991199
assert files == {'foo.py', 'bar.py', os_sep('modsrc/__init__.py')}
12001200
res = cov.report()
12011201
assert res == 100
1202+
1203+
def test_combine_no_suffix_multiprocessing(self):
1204+
self.make_file(".coveragerc", """\
1205+
[run]
1206+
branch = True
1207+
""")
1208+
cov = coverage.Coverage(
1209+
config_file=".coveragerc",
1210+
concurrency="multiprocessing",
1211+
data_suffix=False,
1212+
)
1213+
cov.start()
1214+
cov.stop()
1215+
cov.combine()
1216+
cov.save()
1217+
self.assert_file_count(".coverage.*", 0)
1218+
self.assert_exists(".coverage")

0 commit comments

Comments
 (0)