def __init__(self, attr_type=None, attr=None, required=True, **kwargs): """Attribute constructor. :param attr_type: Type, Schema or constant that does the type conversion of the attribute. :param attr: Attribute name, dot-separated attribute path or an `Accessor` instance. :param required: Is attribute required to be present. """ self.attr_type = attr_type or types.Type() self.attr = attr self.required = required if "default" in kwargs: self.default = kwargs["default"] self.creation_counter = Attr.creation_counter Attr.creation_counter += 1
def test_type(): """Test very basic.""" type_ = types.Type() value = object() assert value is type_.serialize(value) assert value is type_.deserialize(value)