Check for duplicated names when setting element names.

PiperOrigin-RevId: 778827590
Change-Id: I77a208c1571cf735cae80840ea830aa347681f71
This commit is contained in:
Alessio Quaglino
2025-07-03 03:19:51 -07:00
committed by Copybara-Service
parent 594e17074a
commit 564c51ddb9
12 changed files with 96 additions and 74 deletions
+2 -7
View File
@@ -887,7 +887,7 @@ class SpecsTest(absltest.TestCase):
):
s.compile()
def test_recompile_error(self):
def test_duplicate_name_error(self):
main_xml = """
<mujoco>
<worldbody>
@@ -899,16 +899,11 @@ class SpecsTest(absltest.TestCase):
"""
spec = mujoco.MjSpec.from_string(main_xml)
model = spec.compile()
data = mujoco.MjData(model)
spec.add_material().name = 'yellow'
spec.add_material().name = 'yellow'
with self.assertRaisesRegex(
ValueError, "Error: repeated name 'yellow' in material"
):
spec.recompile(model, data)
spec.add_material().name = 'yellow'
def test_delete_unused_plugin(self):
spec = mujoco.MjSpec.from_string("""