(float_value, encoded_str)
| 514 | ], |
| 515 | ) |
| 516 | def test_json_inf_nan_allow(float_value, encoded_str): |
| 517 | class R(RootModel[float]): |
| 518 | model_config = ConfigDict(ser_json_inf_nan='strings') |
| 519 | |
| 520 | r = R(float_value) |
| 521 | r_encoded = f'"{encoded_str}"' |
| 522 | assert r.model_dump_json() == r_encoded |
| 523 | if math.isnan(float_value): |
| 524 | assert math.isnan(R.model_validate_json(r_encoded).root) |
| 525 | else: |
| 526 | assert R.model_validate_json(r_encoded) == r |
| 527 | |
| 528 | class M(BaseModel): |
| 529 | f: float |
| 530 | model_config = R.model_config |
| 531 | |
| 532 | m = M(f=float_value) |
| 533 | m_encoded = f'{{"f":{r_encoded}}}' |
| 534 | assert m.model_dump_json() == m_encoded |
| 535 | if math.isnan(float_value): |
| 536 | assert math.isnan(M.model_validate_json(m_encoded).f) |
| 537 | else: |
| 538 | assert M.model_validate_json(m_encoded) == m |
| 539 | |
| 540 | |
| 541 | def test_json_bytes_base64_round_trip(): |
nothing calls this directly
no test coverage detected