def test_constructor(idcode, name, children, parent, class_): # constructor and cache assert idcode not in Body._CACHE body = Body(idcode) assert idcode in Body._CACHE assert body is Body._CACHE[idcode] assert Body(idcode) is body assert type(body) is class_ # properties assert body.id == idcode assert body.name == name with pytest.raises(AttributeError): body.id = idcode with pytest.raises(AttributeError): body.name = name # parent/children try: assert body.parent().id == parent except AttributeError: assert type(body) is bodies.Barycenter assert body.parent() is None assert [child.id for child in body.children()] == children