| 779 | |
| 780 | |
| 781 | def test_annotated_num(): |
| 782 | @validate_call |
| 783 | def f(a: Annotated[int, Field(gt=0), Field(lt=10)]): |
| 784 | return a |
| 785 | |
| 786 | assert f(5) == 5 |
| 787 | |
| 788 | with pytest.raises(ValidationError) as exc_info: |
| 789 | f(0) |
| 790 | assert exc_info.value.errors(include_url=False) == [ |
| 791 | {'type': 'greater_than', 'loc': (0,), 'msg': 'Input should be greater than 0', 'input': 0, 'ctx': {'gt': 0}} |
| 792 | ] |
| 793 | |
| 794 | with pytest.raises(ValidationError) as exc_info: |
| 795 | f(10) |
| 796 | assert exc_info.value.errors(include_url=False) == [ |
| 797 | {'type': 'less_than', 'loc': (0,), 'msg': 'Input should be less than 10', 'input': 10, 'ctx': {'lt': 10}} |
| 798 | ] |
| 799 | |
| 800 | |
| 801 | def test_annotated_discriminator(): |