MCPcopy
hub / github.com/pydantic/pydantic / test_kwargs

Function test_kwargs

tests/test_deprecated_validate_arguments.py:88–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86
87
88def test_kwargs():
89 @validate_arguments
90 def foo(*, a: int, b: int):
91 return a + b
92
93 assert foo.model.model_fields.keys() == {'a', 'b', 'args', 'kwargs'}
94 assert foo(a=1, b=3) == 4
95
96 with pytest.raises(ValidationError) as exc_info:
97 foo(a=1, b='x')
98
99 assert exc_info.value.errors(include_url=False) == [
100 {
101 'input': 'x',
102 'loc': ('b',),
103 'msg': 'Input should be a valid integer, unable to parse string as an integer',
104 'type': 'int_parsing',
105 }
106 ]
107
108 with pytest.raises(TypeError, match='0 positional arguments expected but 2 given'):
109 foo(1, 'x')
110
111
112def test_untyped():

Callers

nothing calls this directly

Calls 3

keysMethod · 0.80
fooFunction · 0.70
errorsMethod · 0.45

Tested by

no test coverage detected