From 6525fddd1442323cad8898438b9c0ad6ea0e4728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Mon, 18 Mar 2024 05:34:12 +0200 Subject: [PATCH] Refactor some more and revert some of the abspath changes (turns out Path.resolve is no bueno on Python3.9&Windows). --- src/pytest_cov/engine.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pytest_cov/engine.py b/src/pytest_cov/engine.py index 3999a1b..0dab6c0 100644 --- a/src/pytest_cov/engine.py +++ b/src/pytest_cov/engine.py @@ -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 @@ -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' @@ -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, ) @@ -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: