diff --git a/test/test_resolve_robotics_uri_py.py b/test/test_resolve_robotics_uri_py.py index f1aa243..be5d4e1 100644 --- a/test/test_resolve_robotics_uri_py.py +++ b/test/test_resolve_robotics_uri_py.py @@ -94,8 +94,10 @@ def test_scoped_uri(scheme: str, env_var_name="GZ_SIM_RESOURCE_PATH"): # Existing relative URI path in search dirs with export_env_var(name=env_var_name, value=temp_dir): - uri = f"{scheme}sub/level1.txt" - resolve_robotics_uri_py.resolve_robotics_uri(uri) + relative_path = "sub/level1.txt" + uri = f"{scheme}{relative_path}" + path_of_file = resolve_robotics_uri_py.resolve_robotics_uri(uri) + assert path_of_file == (pathlib.Path(temp_dir) / relative_path).resolve() # Existing relative URI path in search dirs with multiple paths with export_env_var(name=env_var_name, value=f"/another/dir:{temp_dir}"): @@ -105,9 +107,10 @@ def test_scoped_uri(scheme: str, env_var_name="GZ_SIM_RESOURCE_PATH"): env_list=resolve_robotics_uri_py.resolve_robotics_uri_py.SupportedEnvVars ) ) - uri = f"{scheme}sub/level1.txt" - resolve_robotics_uri_py.resolve_robotics_uri(uri) - + relative_path = "sub/level1.txt" + uri = f"{scheme}{relative_path}" + path_of_file = resolve_robotics_uri_py.resolve_robotics_uri(uri) + assert path_of_file == (pathlib.Path(temp_dir) / relative_path).resolve() def test_scheme_file(): @@ -127,16 +130,16 @@ def test_scheme_file(): with tempfile.NamedTemporaryFile() as temp: uri_file = f"file://{temp.name}" path_of_file = resolve_robotics_uri_py.resolve_robotics_uri(uri_file) - assert path_of_file == pathlib.Path(temp.name) + assert path_of_file == pathlib.Path(temp.name).resolve() # Existing relative URI path (automatic conversion to absolute) with tempfile.NamedTemporaryFile() as temp: uri_file = f"file:/{temp.name}" path_of_file = resolve_robotics_uri_py.resolve_robotics_uri(uri_file) - assert path_of_file == pathlib.Path(temp.name) + assert path_of_file == pathlib.Path(temp.name).resolve() # Fallback to file:// with no scheme with tempfile.NamedTemporaryFile() as temp: uri_file = f"{temp.name}" path_of_file = resolve_robotics_uri_py.resolve_robotics_uri(uri_file) - assert path_of_file == pathlib.Path(temp.name) + assert path_of_file == pathlib.Path(temp.name).resolve()