()
| 621 | |
| 622 | |
| 623 | def test_decimal_constraints_after_annotation() -> None: |
| 624 | DecimalAnnotation = Annotated[Decimal, BeforeValidator(lambda v: v), Field(max_digits=10, decimal_places=4)] |
| 625 | |
| 626 | ta = TypeAdapter(DecimalAnnotation) |
| 627 | assert ta.validate_python(Decimal('123.4567')) == Decimal('123.4567') |
| 628 | |
| 629 | with pytest.raises(ValidationError) as e: |
| 630 | ta.validate_python(Decimal('123.45678')) |
| 631 | |
| 632 | assert e.value.errors()[0]['type'] == 'decimal_max_places' |
| 633 | |
| 634 | with pytest.raises(ValidationError) as e: |
| 635 | ta.validate_python(Decimal('12345678.901')) |
| 636 | |
| 637 | assert e.value.errors()[0]['type'] == 'decimal_max_digits' |
nothing calls this directly
no test coverage detected