Skip to content

Commit

Permalink
Add additional test for non-existing string path
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Nov 11, 2024
1 parent a1f18c9 commit e0cf6ad
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/test_urdf_parsing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pathlib

import pytest
import robot_descriptions
import robot_descriptions.loaders.idyntree
Expand Down Expand Up @@ -37,15 +39,30 @@ def test_urdf_parsing(robot: Robot) -> None:

# 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)
_ = rod.Sdf.load(sdf="/non/existing/path.sdf", is_urdf=False)

# Check that it fails is is_urdf=True and the resource is an empty string
with pytest.raises(FileNotFoundError):
_ = rod.Sdf.load(sdf=pathlib.Path("/non/existing/path.sdf"), 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)
_ = rod.Sdf.load(sdf=str(urdf_path), is_urdf=None)
_ = rod.Sdf.load(sdf=str(urdf_path), is_urdf=True)
_ = rod.Sdf.load(sdf=urdf_path.read_text(), is_urdf=True)
_ = rod.Sdf.load(
sdf="<robot name='minimal_robot'> \
<link name='base_link'/> \
<joint name='base_to_link1' type='continuous'> \
<parent link='base_link'/> \
<child link='link1'/> \
<origin xyz='0 0 1' rpy='0 0 0'/> \
</joint> \
<link name='link1'/> \
</robot> \
"
)

# Load once again the urdf
rod_sdf = rod.Sdf.load(sdf=urdf_path)
Expand Down

0 comments on commit e0cf6ad

Please sign in to comment.