Skip to content

Commit

Permalink
Refactor some more and revert some of the abspath changes (turns out …
Browse files Browse the repository at this point in the history
…Path.resolve is no bueno on Python3.9&Windows).
  • Loading branch information
ionelmc committed Mar 18, 2024
1 parent 61ce622 commit 6525fdd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pytest_cov/engine.py
Expand Up @@ -69,7 +69,7 @@ def __init__(self, cov_source, cov_report, cov_config, cov_append, cov_branch, c
self.data_file = None
self.node_descs = set()
self.failed_workers = []
self.topdir = str(Path.cwd())
self.topdir = os.fspath(Path.cwd())
self.is_collocated = None

@contextlib.contextmanager
Expand All @@ -96,12 +96,13 @@ def set_env(self):
os.environ['COV_CORE_SOURCE'] = os.pathsep
else:
os.environ['COV_CORE_SOURCE'] = os.pathsep.join(self.cov_source)
config_file = Path(self.cov_config).resolve()
config_file = Path(self.cov_config)
if config_file.exists():
os.environ['COV_CORE_CONFIG'] = str(config_file)
os.environ['COV_CORE_CONFIG'] = os.fspath(config_file.resolve())
else:
os.environ['COV_CORE_CONFIG'] = os.pathsep
os.environ['COV_CORE_DATAFILE'] = str(Path(self.cov.config.data_file).resolve())
# this still uses the old abspath cause apparently Python 3.9 on Windows has a buggy Path.resolve()
os.environ['COV_CORE_DATAFILE'] = os.path.abspath(self.cov.config.data_file) # noqa: PTH100
if self.cov_branch:
os.environ['COV_CORE_BRANCH'] = 'enabled'

Expand Down Expand Up @@ -236,7 +237,7 @@ def start(self):
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_file=str(Path(self.cov.config.data_file).resolve()),
data_file=os.path.abspath(self.cov.config.data_file), # noqa: PTH100
config_file=self.cov_config,
)

Expand Down Expand Up @@ -283,7 +284,7 @@ def start(self):
source=self.cov_source,
branch=self.cov_branch,
data_suffix=True,
data_file=str(Path(self.cov.config.data_file).resolve()),
data_file=os.path.abspath(self.cov.config.data_file), # noqa: PTH100
config_file=self.cov_config,
)
if not self.cov_append:
Expand Down

0 comments on commit 6525fdd

Please sign in to comment.