MCPcopy
hub / github.com/pydantic/pydantic / test_args_name

Function test_args_name

tests/test_deprecated_validate_arguments.py:170–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

168
169
170def test_args_name():
171 @validate_arguments
172 def foo(args: int, kwargs: int):
173 return f'args={args!r}, kwargs={kwargs!r}'
174
175 assert foo.model.model_fields.keys() == {'args', 'kwargs', 'v__args', 'v__kwargs', 'v__duplicate_kwargs'}
176 assert foo(1, 2) == 'args=1, kwargs=2'
177
178 with pytest.raises(TypeError, match="unexpected keyword argument: 'apple'"):
179 foo(1, 2, apple=4)
180
181 with pytest.raises(TypeError, match="unexpected keyword arguments: 'apple', 'banana'"):
182 foo(1, 2, apple=4, banana=5)
183
184 with pytest.raises(TypeError, match='2 positional arguments expected but 3 given'):
185 foo(1, 2, 3)
186
187
188def test_v_args():

Callers

nothing calls this directly

Calls 2

keysMethod · 0.80
fooFunction · 0.70

Tested by

no test coverage detected