(self)
| 162 | test_invalid_attr_recursively(mujoco) |
| 163 | |
| 164 | def testAdd(self): |
| 165 | mujoco = element.RootElement(model='test') |
| 166 | |
| 167 | # repeated elements |
| 168 | body_foo_attributes = dict(name='foo', pos=[0, 1, 0], quat=[0, 1, 0, 0]) |
| 169 | body_foo = mujoco.worldbody.add('body', **body_foo_attributes) |
| 170 | self.assertEqual(body_foo.tag, 'body') |
| 171 | joint_foo_attributes = dict(name='foo', type='free') |
| 172 | joint_foo = body_foo.add('joint', **joint_foo_attributes) |
| 173 | self.assertEqual(joint_foo.tag, 'joint') |
| 174 | self._test_properties(body_foo, parent=mujoco.worldbody, root=mujoco) |
| 175 | self._test_attributes(body_foo, expected_values=body_foo_attributes) |
| 176 | self._test_children(body_foo) |
| 177 | self._test_properties(joint_foo, parent=body_foo, root=mujoco) |
| 178 | self._test_attributes(joint_foo, expected_values=joint_foo_attributes) |
| 179 | self._test_children(joint_foo) |
| 180 | |
| 181 | # non-repeated, on-demand elements |
| 182 | self.assertIsNone(body_foo.inertial) |
| 183 | body_foo_inertial_attributes = dict(mass=1.0, pos=[0, 0, 0]) |
| 184 | body_foo_inertial = body_foo.add('inertial', **body_foo_inertial_attributes) |
| 185 | self._test_properties(body_foo_inertial, parent=body_foo, root=mujoco) |
| 186 | self._test_attributes(body_foo_inertial, |
| 187 | expected_values=body_foo_inertial_attributes) |
| 188 | self._test_children(body_foo_inertial) |
| 189 | |
| 190 | with self.assertRaisesRegex(ValueError, '<inertial> child already exists'): |
| 191 | body_foo.add('inertial', **body_foo_inertial_attributes) |
| 192 | |
| 193 | # non-repeated, non-on-demand elements |
| 194 | with self.assertRaisesRegex(ValueError, '<compiler> child already exists'): |
| 195 | mujoco.add('compiler') |
| 196 | self.assertIsNotNone(mujoco.compiler) |
| 197 | with self.assertRaisesRegex(ValueError, '<default> child already exists'): |
| 198 | mujoco.add('default') |
| 199 | self.assertIsNotNone(mujoco.default) |
| 200 | |
| 201 | def testInsert(self): |
| 202 | mujoco = element.RootElement(model='test') |
nothing calls this directly
no test coverage detected