コード例 #1
0
def test_field_required():
    field = DynamicArrayField(CharField(max_length=10), required=True)
    data = []
    with pytest.raises(ValidationError):
        field.clean(data)
    data = ["12", "13"]
    field.clean(data)
コード例 #2
0
def test_default():
    default = ["1"]
    field = DynamicArrayField(CharField(max_length=10),
                              required=True,
                              default=default)
    data = []
    cleaned_data = field.clean(data)
    assert cleaned_data == default
コード例 #3
0
def test_field_not_required():
    field = DynamicArrayField(CharField(max_length=10), required=False)
    data = []
    field.clean(data)
    data = ["12", "13"]
    field.clean(data)