MCPcopy
hub / github.com/pydantic/pydantic / test_chain_schema

Function test_chain_schema

tests/test_json_schema.py:6000–6006  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5998
5999
6000def test_chain_schema():
6001 # this is a contrived schema which requires a string input that can be coerced to an int:
6002 s = core_schema.chain_schema([core_schema.str_schema(), core_schema.int_schema()])
6003 assert SchemaValidator(s).validate_python('1') == 1 # proof it works this way
6004
6005 assert GenerateJsonSchema().generate(s, mode='validation') == {'type': 'string'}
6006 assert GenerateJsonSchema().generate(s, mode='serialization') == {'type': 'integer'}
6007
6008
6009def test_deferred_json_schema():

Callers

nothing calls this directly

Calls 6

GenerateJsonSchemaClass · 0.90
chain_schemaMethod · 0.80
str_schemaMethod · 0.80
int_schemaMethod · 0.80
validate_pythonMethod · 0.45
generateMethod · 0.45

Tested by

no test coverage detected