()
| 337 | |
| 338 | |
| 339 | def test_merge_field_infos_ordering() -> None: |
| 340 | TheType = Annotated[int, AfterValidator(lambda x: x), Field(le=2), AfterValidator(lambda x: x * 2), Field(lt=4)] |
| 341 | |
| 342 | class Model(BaseModel): |
| 343 | x: TheType |
| 344 | |
| 345 | assert Model(x=1).x == 2 |
| 346 | |
| 347 | with pytest.raises(ValidationError) as exc_info: |
| 348 | Model(x=2) |
| 349 | # insert_assert(exc_info.value.errors(include_url=False)) |
| 350 | assert exc_info.value.errors(include_url=False) == [ |
| 351 | {'type': 'less_than', 'loc': ('x',), 'msg': 'Input should be less than 4', 'input': 2, 'ctx': {'lt': 4}} |
| 352 | ] |
| 353 | |
| 354 | with pytest.raises(ValidationError) as exc_info: |
| 355 | Model(x=3) |
| 356 | # insert_assert(exc_info.value.errors(include_url=False)) |
| 357 | assert exc_info.value.errors(include_url=False) == [ |
| 358 | { |
| 359 | 'type': 'less_than_equal', |
| 360 | 'loc': ('x',), |
| 361 | 'msg': 'Input should be less than or equal to 2', |
| 362 | 'input': 3, |
| 363 | 'ctx': {'le': 2}, |
| 364 | } |
| 365 | ] |
| 366 | |
| 367 | |
| 368 | def test_validate_float_inf_nan_python() -> None: |
nothing calls this directly
no test coverage detected