()
| 539 | |
| 540 | |
| 541 | def test_json_bytes_base64_round_trip(): |
| 542 | class R(RootModel[bytes]): |
| 543 | model_config = ConfigDict(ser_json_bytes='base64', val_json_bytes='base64') |
| 544 | |
| 545 | r = R(b'hello') |
| 546 | r_encoded = '"aGVsbG8="' |
| 547 | assert r.model_dump_json() == r_encoded |
| 548 | assert R.model_validate_json(r_encoded) == r |
| 549 | |
| 550 | class M(BaseModel): |
| 551 | key: bytes |
| 552 | model_config = R.model_config |
| 553 | |
| 554 | m = M(key=b'hello') |
| 555 | m_encoded = f'{{"key":{r_encoded}}}' |
| 556 | assert m.model_dump_json() == m_encoded |
| 557 | assert M.model_validate_json(m_encoded) == m |
| 558 | |
| 559 | |
| 560 | def test_json_bytes_hex_round_trip(): |
nothing calls this directly
no test coverage detected