Skip to content

Commit

Permalink
Add explicit suffixing to make it easier to see the identify the sour…
Browse files Browse the repository at this point in the history
…ces/usages of the data files.
  • Loading branch information
ionelmc committed Sep 23, 2024
1 parent c87e546 commit c299e01
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/pytest_cov/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import coverage
from coverage.data import CoverageData
from coverage.sqldata import filename_suffix

from .embed import cleanup

Expand Down Expand Up @@ -51,6 +52,10 @@ def ensure_topdir_wrapper(self, *args, **kwargs):
return ensure_topdir_wrapper


def _data_suffix(name):
return f'{filename_suffix(True)}.{name}'


class CovController:
"""Base class for different plugin implementations."""

Expand Down Expand Up @@ -230,13 +235,13 @@ def start(self):
self.cov = coverage.Coverage(
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_suffix=_data_suffix('c'),
config_file=self.cov_config,
)
self.combining_cov = coverage.Coverage(
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_suffix=_data_suffix('cc'),
data_file=os.path.abspath(self.cov.config.data_file), # noqa: PTH100
config_file=self.cov_config,
)
Expand Down Expand Up @@ -274,7 +279,7 @@ def start(self):
self.cov = coverage.Coverage(
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_suffix=_data_suffix('m'),
config_file=self.cov_config,
)
self.cov._warn_no_data = False
Expand All @@ -283,7 +288,7 @@ def start(self):
self.combining_cov = coverage.Coverage(
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_suffix=_data_suffix('mc'),
data_file=os.path.abspath(self.cov.config.data_file), # noqa: PTH100
config_file=self.cov_config,
)
Expand Down Expand Up @@ -330,7 +335,7 @@ def testnodedown(self, node, error):
data.read_fileobj(StringIO(output['cov_worker_data']))
cov.data.update(data)
else:
data = CoverageData(no_disk=True)
data = CoverageData(no_disk=True, suffix='should-not-exist')
data.loads(output['cov_worker_data'])
cov.get_data().update(data)
cov.stop()
Expand Down Expand Up @@ -381,7 +386,7 @@ def start(self):
self.cov = coverage.Coverage(
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_suffix=_data_suffix(f'w{self.nodeid}'),
config_file=self.cov_config,
)
self.cov.start()
Expand Down

0 comments on commit c299e01

Please sign in to comment.