()
| 366 | |
| 367 | |
| 368 | def test_validate_float_inf_nan_python() -> None: |
| 369 | ta = TypeAdapter(Annotated[float, AfterValidator(lambda x: x * 3), Field(allow_inf_nan=False)]) |
| 370 | assert ta.validate_python(2.0) == 6.0 |
| 371 | |
| 372 | ta = TypeAdapter(Annotated[float, AfterValidator(lambda _: float('nan')), Field(allow_inf_nan=False)]) |
| 373 | |
| 374 | with pytest.raises(ValidationError) as exc_info: |
| 375 | ta.validate_python(1.0) |
| 376 | |
| 377 | # insert_assert(exc_info.value.errors(include_url=False)) |
| 378 | # TODO: input should be float('nan'), this seems like a subtle bug in pydantic-core |
| 379 | assert exc_info.value.errors(include_url=False) == [ |
| 380 | {'type': 'finite_number', 'loc': (), 'msg': 'Input should be a finite number', 'input': 1.0} |
| 381 | ] |
| 382 | |
| 383 | |
| 384 | def test_predicate_success_python() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…