def test_raw_field_allow_null(): field = RawField("field that allows nulls", allow_null=True) assert field.from_representation(None) is None assert field.from_representation("foo") == "foo" assert field.to_representation(None) is None assert field.to_representation("foo") == "foo"
def test_raw_field(data_type): field = RawField(None, None) instance = data_type() representation = field.to_representation(instance) assert isinstance(representation, data_type) assert instance == representation recreated = field.from_representation(representation) assert isinstance(recreated, data_type) assert instance == recreated