Skip to content

Commit 6525fdd

Browse files
committed
Refactor some more and revert some of the abspath changes (turns out Path.resolve is no bueno on Python3.9&Windows).
1 parent 61ce622 commit 6525fdd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/pytest_cov/engine.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, cov_source, cov_report, cov_config, cov_append, cov_branch, c
6969
self.data_file = None
7070
self.node_descs = set()
7171
self.failed_workers = []
72-
self.topdir = str(Path.cwd())
72+
self.topdir = os.fspath(Path.cwd())
7373
self.is_collocated = None
7474

7575
@contextlib.contextmanager
@@ -96,12 +96,13 @@ def set_env(self):
9696
os.environ['COV_CORE_SOURCE'] = os.pathsep
9797
else:
9898
os.environ['COV_CORE_SOURCE'] = os.pathsep.join(self.cov_source)
99-
config_file = Path(self.cov_config).resolve()
99+
config_file = Path(self.cov_config)
100100
if config_file.exists():
101-
os.environ['COV_CORE_CONFIG'] = str(config_file)
101+
os.environ['COV_CORE_CONFIG'] = os.fspath(config_file.resolve())
102102
else:
103103
os.environ['COV_CORE_CONFIG'] = os.pathsep
104-
os.environ['COV_CORE_DATAFILE'] = str(Path(self.cov.config.data_file).resolve())
104+
# this still uses the old abspath cause apparently Python 3.9 on Windows has a buggy Path.resolve()
105+
os.environ['COV_CORE_DATAFILE'] = os.path.abspath(self.cov.config.data_file) # noqa: PTH100
105106
if self.cov_branch:
106107
os.environ['COV_CORE_BRANCH'] = 'enabled'
107108

@@ -236,7 +237,7 @@ def start(self):
236237
source=self.cov_source,
237238
branch=self.cov_branch,
238239
data_suffix=True,
239-
data_file=str(Path(self.cov.config.data_file).resolve()),
240+
data_file=os.path.abspath(self.cov.config.data_file), # noqa: PTH100
240241
config_file=self.cov_config,
241242
)
242243

@@ -283,7 +284,7 @@ def start(self):
283284
source=self.cov_source,
284285
branch=self.cov_branch,
285286
data_suffix=True,
286-
data_file=str(Path(self.cov.config.data_file).resolve()),
287+
data_file=os.path.abspath(self.cov.config.data_file), # noqa: PTH100
287288
config_file=self.cov_config,
288289
)
289290
if not self.cov_append:

0 commit comments

Comments
 (0)