MCPcopy
hub / github.com/pydantic/pydantic / test_subclass_bytes

Function test_subclass_bytes

pydantic-core/tests/serializers/test_bytes.py:93–103  ·  view source on GitHub ↗
(schema_type, input_value, expected_json)

Source from the content-addressed store, hash-verified

91 [(BytesSubclass(b'foo'), 'foo'), (BytesMixin(b'foo'), 'foo'), (BytesEnum.foo, 'foo-value')],
92)
93def test_subclass_bytes(schema_type, input_value, expected_json):
94 s = SchemaSerializer({'type': schema_type})
95 v = s.to_python(input_value)
96 assert v == input_value
97 assert type(v) == type(input_value)
98
99 v = s.to_python(input_value, mode='json')
100 assert v == expected_json
101 assert type(v) == str
102
103 assert s.to_json(input_value) == json.dumps(expected_json).encode('utf-8')
104
105
106def test_bytes_base64():

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected