Ejemplo n.º 1
0
def test_validate_elements_invalid():
    """
    When a DictField is given a dict containing values that are invalid for the value-field, then
    validate should raise a ValidationError.
    """
    field = DictField(CharField(max_length=5))
    with pytest.raises(ValidationError):
        field.run_validators({"a": "012345", "b": "012345"})
Ejemplo n.º 2
0
def test_validate_elements_valid():
    """
    When a DictField is given a dict whose values are valid for the value-field, then validate
    should not raise a ValidationError.
    """
    field = DictField(CharField(max_length=5))
    try:
        field.run_validators({"a": "a", "b": "b", "c": "c"})
    except ValidationError:
        assert False, "ValidationError was raised"