diff --git a/src/rod/sdf/sdf.py b/src/rod/sdf/sdf.py index 74e133d..1eed007 100644 --- a/src/rod/sdf/sdf.py +++ b/src/rod/sdf/sdf.py @@ -69,24 +69,21 @@ def load(sdf: pathlib.Path | str, is_urdf: bool | None = None) -> Sdf: # Check if the input is a string path. is_str_path = getattr(sdf, "__len__", lambda: MAX_PATH + 1)() <= MAX_PATH - if is_urdf is not None: - sdf_string = sdf - else: - match sdf: - # Case 1: Handle SDF/URDF string. - case str() if not is_str_path: - sdf_string = sdf - is_urdf = " None: with pytest.raises(RuntimeError): _ = rod.Sdf.load(sdf=urdf_path.read_text(), is_urdf=False) + # Check that it fails is is_urdf=True and the resource is a non-existing path + with pytest.raises(FileNotFoundError): + _ = rod.Sdf.load(sdf="/non/existing/path", is_urdf=None) + _ = rod.Sdf.load(sdf="/non/existing/path", is_urdf=False) + # The following instead should succeed _ = rod.Sdf.load(sdf=urdf_path, is_urdf=None) _ = rod.Sdf.load(sdf=urdf_path, is_urdf=True)