Пример #1
0
def test_field_validation() -> None:
    """Custom field validation should behave correctly."""
    def _validate(context: ValidationContext, _: str) -> None:
        assert isinstance(context, ValidationContext)
        context.error("Test")

    class _Test:
        fields = {"field": StringField(validate=_validate)}

    check_field_error(_Test, "field", "value", ErrorCode.VALIDATION_ERROR)
Пример #2
0
def _check_field_error(yaml_value: str, expected_error: ErrorCode) -> None:
    check_field_error(_Test, "path", yaml_value, expected_error)
Пример #3
0
def _check_field_error(field: str, yml_value: str,
                       expected_error: ErrorCode) -> None:
    check_field_error(_Test, field, yml_value, expected_error)
Пример #4
0
def _check_field_error(yml_value: str, expected_error: ErrorCode) -> None:
    check_field_error(_Test, "enum", yml_value, expected_error)
Пример #5
0
def _check_field_error(yaml_value: str, expected_error: ErrorCode) -> None:
    check_field_error(_Owner, "field", yaml_value, expected_error)