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)
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
def test_field_not_required(): field = DynamicArrayField(CharField(max_length=10), required=False) data = [] field.clean(data) data = ["12", "13"] field.clean(data)