MCPcopy
hub / github.com/pydantic/pydantic / test_json_schema_arguments_v3

Function test_json_schema_arguments_v3

tests/test_json_schema.py:6972–6997  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6970
6971
6972def test_json_schema_arguments_v3() -> None:
6973 schema = core_schema.arguments_v3_schema(
6974 [
6975 core_schema.arguments_v3_parameter(name='a', schema=core_schema.int_schema(), mode='positional_only'),
6976 core_schema.arguments_v3_parameter(name='b', schema=core_schema.int_schema(), mode='positional_or_keyword'),
6977 core_schema.arguments_v3_parameter(name='c', schema=core_schema.int_schema(), mode='var_args'),
6978 core_schema.arguments_v3_parameter(
6979 name='d',
6980 schema=core_schema.with_default_schema(core_schema.int_schema(), default=1),
6981 mode='keyword_only',
6982 ),
6983 core_schema.arguments_v3_parameter(name='e', schema=core_schema.int_schema(), mode='var_kwargs_uniform'),
6984 ],
6985 )
6986
6987 assert GenerateJsonSchema().generate(schema) == {
6988 'type': 'object',
6989 'properties': {
6990 'a': {'type': 'integer', 'title': 'A'},
6991 'b': {'type': 'integer', 'title': 'B'},
6992 'c': {'type': 'array', 'items': {'type': 'integer'}, 'title': 'C'},
6993 'd': {'type': 'integer', 'title': 'D', 'default': 1},
6994 'e': {'type': 'object', 'additionalProperties': {'type': 'integer'}, 'title': 'E'},
6995 },
6996 'required': ['a', 'b'],
6997 }
6998
6999
7000def test_json_schema_arguments_v3_var_kwargs_unpacked_typed_dict_required() -> None:

Callers

nothing calls this directly

Calls 4

GenerateJsonSchemaClass · 0.90
arguments_v3_schemaMethod · 0.80
int_schemaMethod · 0.80
generateMethod · 0.45

Tested by

no test coverage detected