def _map_nodes(self, node, references): fields = [ self._transform_field(getattr(node, field.name), references) for field in dodge.fields(node) ] new_node = type(node)(*fields) # TODO: test location preservation location = getattr(node, "location", None) if location is not None: new_node.location = location return new_node
def fields_of_instance_can_be_retrieved(): User = dodge.data_class("User", ["username"]) user = User("bob") field, = dodge.fields(user) assert_equal("username", field.name)