From 0c24d69fc7fe8913bd60f4f1fcef4ed78e45b10a Mon Sep 17 00:00:00 2001 From: Satoru SATOH Date: Mon, 6 May 2024 21:38:22 +0900 Subject: [PATCH] fix: another workaround for non-unix platforms especially windows (use pathlib.Path.parts, zip_longest) --- tests/common/tdc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/common/tdc.py b/tests/common/tdc.py index e3ab7e07..715433b2 100644 --- a/tests/common/tdc.py +++ b/tests/common/tdc.py @@ -6,6 +6,7 @@ r"""Test Data Collecor.""" from __future__ import annotations +import itertools import os.path import pathlib import re @@ -47,7 +48,10 @@ def get_test_resdir( """ path = pathlib.Path(testfile).resolve() subdir = pattern.match(path.name).groups()[0] - relpath = str(path.parent).replace(f"{topdir!s}{os.path.sep}", "") + relpath = os.path.join( + *[x for x, y in itertools.zip_longest(path.parent.parts, topdir.parts) + if y is None] + ) return resdir / relpath / subdir