MCPcopy
hub / github.com/pydantic/pydantic / test_wrap

Function test_wrap

tests/test_deprecated_validate_arguments.py:67–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66
67def test_wrap():
68 @validate_arguments
69 def foo_bar(a: int, b: int):
70 """This is the foo_bar method."""
71 return f'{a}, {b}'
72
73 assert foo_bar.__doc__ == 'This is the foo_bar method.'
74 assert foo_bar.__name__ == 'foo_bar'
75 assert foo_bar.__module__ == 'tests.test_deprecated_validate_arguments'
76 assert foo_bar.__qualname__ == 'test_wrap.<locals>.foo_bar'
77 assert isinstance(foo_bar.vd, ValidatedFunction)
78 assert callable(foo_bar.raw_function)
79 assert foo_bar.vd.arg_mapping == {0: 'a', 1: 'b'}
80 assert foo_bar.vd.positional_only_args == set()
81 assert issubclass(foo_bar.model, BaseModel)
82 assert foo_bar.model.model_fields.keys() == {'a', 'b', 'args', 'kwargs', 'v__duplicate_kwargs'}
83 assert foo_bar.model.__name__ == 'FooBar'
84 assert foo_bar.model.model_json_schema()['title'] == 'FooBar'
85 assert repr(inspect.signature(foo_bar)) == '<Signature (a: int, b: int)>'
86
87
88def test_kwargs():

Callers

nothing calls this directly

Calls 2

keysMethod · 0.80
model_json_schemaMethod · 0.45

Tested by

no test coverage detected