| 168 | |
| 169 | |
| 170 | def 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 | |
| 188 | def test_v_args(): |