()
| 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(&class="cm">#x27;nan')), Field(allow_inf_nan=False)]) |
| 373 | |
| 374 | with pytest.raises(ValidationError) as exc_info: |
| 375 | ta.validate_python(1.0) |
| 376 | |
| 377 | class="cm"># insert_assert(exc_info.value.errors(include_url=False)) |
| 378 | class="cm"># TODO: input should be float(class="st">'nan'), this seems like a subtle bug in pydantic-core |
| 379 | assert exc_info.value.errors(include_url=False) == [ |
| 380 | {&class="cm">#x27;typeclass="st">': 'finite_numberclass="st">', 'locclass="st">': (), 'msgclass="st">': 'Input should be a finite numberclass="st">', 'input': 1.0} |
| 381 | ] |
| 382 | |
| 383 | |
| 384 | def test_predicate_success_python() -> None: |
nothing calls this directly
no test coverage detected