示例#1
0
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"
示例#2
0
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"
示例#3
0
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
示例#4
0
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