Skip to content

Commit 305b68e

Browse files
yuvaltassacopybara-github
authored andcommitted
Add tests for body.find_all() of joints and geoms, fix error message.
Fixes #2525 PiperOrigin-RevId: 742685596 Change-Id: I5f0969967f2490d32e5691983e8d0c363d48a6bd
1 parent c0a7ea1 commit 305b68e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

python/mujoco/specs.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ py::list FindAllImpl(raw::MjsBody& body, mjtObj objtype, bool recursive) {
261261
// this should never happen
262262
throw pybind11::value_error(
263263
"body.find_all supports the types: body, frame, geom, site, "
264-
"light, camera.");
264+
"joint, light, camera.");
265265
break;
266266
}
267267
el = mjs_nextChild(&body, el, recursive);

python/mujoco/specs_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ def test_body_list(self):
636636
<site name="site4"/>
637637
<body name="body4">
638638
<site name="site5"/>
639+
<joint name="joint1"/>
640+
<geom name="geom1" size="1"/>
639641
</body>
640642
</body>
641643
</body>
@@ -649,6 +651,8 @@ def test_body_list(self):
649651
self.assertLen(spec.sites, 5)
650652
self.assertLen(spec.worldbody.find_all('body'), 4)
651653
self.assertLen(spec.worldbody.find_all('site'), 5)
654+
self.assertLen(spec.worldbody.find_all('joint'), 1)
655+
self.assertLen(spec.worldbody.find_all('geom'), 1)
652656
self.assertEqual(spec.bodies[1].name, 'body1')
653657
self.assertEqual(spec.bodies[2].name, 'body2')
654658
self.assertEqual(spec.bodies[3].name, 'body3')

0 commit comments

Comments
 (0)