예제 #1
0
def test_validate_elements_invalid():
    """
    When a ListField is given a list containing elements that are invalid for the item-field, then
    validate should raise a ValidationError.
    """
    field = ListField(CharField(max_length=5))
    with pytest.raises(ValidationError):
        field.run_validators(["012345", "012345"])
예제 #2
0
def test_validate_elements_valid():
    """
    When a ListField is given a list whose elements are valid for the item-field, then validate
    should not raise a ValidationError.
    """
    field = ListField(CharField(max_length=5))
    try:
        field.run_validators(["a", "b", "c"])
    except ValidationError:
        assert False, "ValidationError was raised"