diff --git a/src/pytest_cov/engine.py b/src/pytest_cov/engine.py index 02590aea..88d2b359 100644 --- a/src/pytest_cov/engine.py +++ b/src/pytest_cov/engine.py @@ -12,6 +12,7 @@ import coverage from coverage.data import CoverageData +from coverage.sqldata import filename_suffix from .embed import cleanup @@ -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.""" @@ -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, ) @@ -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 @@ -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, ) @@ -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() @@ -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()