(self)
| 62 | .format(name, str(e))) |
| 63 | |
| 64 | def testLoadXML(self): |
| 65 | with open(HUMANOID_XML_PATH, "r") as f: |
| 66 | xml_string = f.read() |
| 67 | model = core.MjModel.from_xml_string(xml_string) |
| 68 | core.MjData(model) |
| 69 | with self.assertRaises(TypeError): |
| 70 | core.MjModel() |
| 71 | with self.assertRaises(ValueError): |
| 72 | core.MjModel.from_xml_path("/path/to/nonexistent/model/file.xml") |
| 73 | |
| 74 | xml_with_warning = """ |
| 75 | <mujoco> |
| 76 | <size njmax='2'/> |
| 77 | <worldbody> |
| 78 | <body pos='0 0 0'> |
| 79 | <geom type='box' size='.1 .1 .1'/> |
| 80 | </body> |
| 81 | <body pos='0 0 0'> |
| 82 | <joint type='slide' axis='1 0 0'/> |
| 83 | <geom type='box' size='.1 .1 .1'/> |
| 84 | </body> |
| 85 | </worldbody> |
| 86 | </mujoco>""" |
| 87 | |
| 88 | # This model should compile successfully, but raise a warning on the first |
| 89 | # simulation step. |
| 90 | model = core.MjModel.from_xml_string(xml_with_warning) |
| 91 | data = core.MjData(model) |
| 92 | mujoco.mj_step(model.ptr, data.ptr) |
| 93 | |
| 94 | def testLoadXMLWithAssetsFromString(self): |
| 95 | core.MjModel.from_xml_string(MODEL_WITH_ASSETS, assets=ASSETS) |
nothing calls this directly
no test coverage detected