()
| 8 | |
| 9 | |
| 10 | def test_bytes(): |
| 11 | s = SchemaSerializer(core_schema.bytes_schema()) |
| 12 | assert s.to_python(b'foobar') == b'foobar' |
| 13 | assert s.to_python('emoji 💩'.encode()) == 'emoji 💩'.encode() |
| 14 | assert s.to_json(b'foobar') == b'"foobar"' |
| 15 | assert s.to_python(b'foobar', mode='json') == 'foobar' |
| 16 | |
| 17 | json_emoji = s.to_json('emoji 💩'.encode()) |
| 18 | # note! serde_json serializes unicode characters differently |
| 19 | assert json_emoji == b'"emoji \xf0\x9f\x92\xa9"' |
| 20 | assert json.loads(json_emoji) == 'emoji 💩' |
| 21 | |
| 22 | |
| 23 | def test_bytes_invalid_all(): |
nothing calls this directly
no test coverage detected