def test_fields_can_fail_to_select_validators(): # Given that I have an instance of a field with a nonstandard annotation and validator options field = Field("example", None, minimum=10) # When I call its select_validator method # Then a RuntimeError should be raised with pytest.raises(RuntimeError): field.select_validator()
def test_fields_with_optional_unions(annotation, value, expected): field = Field(annotation=annotation) field.select_validator() assert field.validate(value) == expected