diff --git a/pydsdl/_dsdl_definition.py b/pydsdl/_dsdl_definition.py index 93addb1..bda5eb4 100644 --- a/pydsdl/_dsdl_definition.py +++ b/pydsdl/_dsdl_definition.py @@ -33,9 +33,9 @@ class DSDLDefinition: def __init__(self, file_path: Path, root_namespace_path: Path): # Normalizing the path and reading the definition text - self._file_path = Path(file_path).resolve() + self._file_path = Path(file_path) del file_path - self._root_namespace_path = Path(root_namespace_path).resolve() + self._root_namespace_path = Path(root_namespace_path) del root_namespace_path with open(self._file_path) as f: self._text = str(f.read()) @@ -48,7 +48,7 @@ def __init__(self, file_path: Path, root_namespace_path: Path): relative_path = str( os.path.join( os.path.split(self._root_namespace_path)[-1], - os.path.relpath(self._file_path, self._root_namespace_path), + self._file_path.relative_to(self._root_namespace_path), ) ) diff --git a/pydsdl/_namespace.py b/pydsdl/_namespace.py index b6f19c8..0d0bc97 100644 --- a/pydsdl/_namespace.py +++ b/pydsdl/_namespace.py @@ -440,7 +440,7 @@ def on_walk_error(os_ex: Exception) -> None: for root, _dirnames, filenames in walker: for glb in _DSDL_FILE_GLOBS: for filename in fnmatch.filter(filenames, glb): - source_file_paths.add(Path(root, filename).resolve()) + source_file_paths.add(Path(root, filename)) output = [] # type: List[_dsdl_definition.DSDLDefinition] for fp in sorted(source_file_paths): diff --git a/pydsdl/_test.py b/pydsdl/_test.py index ddc6f3f..2872f80 100644 --- a/pydsdl/_test.py +++ b/pydsdl/_test.py @@ -70,8 +70,8 @@ def _unittest_define() -> None: assert d.full_name == "uavcan.test.Message" assert d.version == (1, 2) assert d.fixed_port_id == 5000 - assert d.file_path == Path(_DIRECTORY.name, "uavcan", "test", "5000.Message.1.2.dsdl").resolve() - assert d.root_namespace_path == Path(_DIRECTORY.name, "uavcan").resolve() + assert d.file_path.samefile(Path(_DIRECTORY.name, "uavcan", "test", "5000.Message.1.2.dsdl")) + assert d.root_namespace_path.samefile(Path(_DIRECTORY.name, "uavcan")) assert open(d.file_path).read() == "# empty" # BUT WHEN I DO, I WRITE UNIT TESTS FOR MY UNIT TESTS @@ -79,8 +79,8 @@ def _unittest_define() -> None: assert d.full_name == "uavcan.Service" assert d.version == (255, 254) assert d.fixed_port_id is None - assert d.file_path == Path(_DIRECTORY.name, "uavcan", "Service.255.254.dsdl").resolve() - assert d.root_namespace_path == Path(_DIRECTORY.name, "uavcan").resolve() + assert d.file_path.samefile(Path(_DIRECTORY.name, "uavcan", "Service.255.254.dsdl")) + assert d.root_namespace_path.samefile(Path(_DIRECTORY.name, "uavcan")) assert open(d.file_path).read() == "# empty 2"