MCPcopy
hub / github.com/pydantic/pydantic / test_subclass_str

Function test_subclass_str

pydantic-core/tests/serializers/test_string.py:172–182  ·  view source on GitHub ↗
(schema_type, input_value, expected)

Source from the content-addressed store, hash-verified

170 'input_value,expected', [(StrSubclass('foo'), 'foo'), (StrMixin('foo'), 'foo'), (StrEnum.foo, 'foo-value')]
171)
172def test_subclass_str(schema_type, input_value, expected):
173 s = SchemaSerializer({'type': schema_type})
174 v = s.to_python(input_value)
175 assert v == input_value
176 assert type(v) == type(input_value)
177
178 v = s.to_python(input_value, mode='json')
179 assert v == expected
180 assert type(v) == str
181
182 assert s.to_json(input_value) == json.dumps(expected).encode('utf-8')

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected