| 487 | |
| 488 | |
| 489 | def test_args_name(): |
| 490 | @validate_call |
| 491 | def foo(args: int, kwargs: int): |
| 492 | return f'args={args!r}, kwargs={kwargs!r}' |
| 493 | |
| 494 | assert foo(1, 2) == 'args=1, kwargs=2' |
| 495 | |
| 496 | with pytest.raises(ValidationError, match=r'apple\s+Unexpected keyword argument'): |
| 497 | foo(1, 2, apple=4) |
| 498 | |
| 499 | with pytest.raises(ValidationError) as exc_info: |
| 500 | foo(1, 2, apple=4, banana=5) |
| 501 | |
| 502 | # insert_assert(exc_info.value.errors(include_url=False)) |
| 503 | assert exc_info.value.errors(include_url=False) == [ |
| 504 | {'type': 'unexpected_keyword_argument', 'loc': ('apple',), 'msg': 'Unexpected keyword argument', 'input': 4}, |
| 505 | {'type': 'unexpected_keyword_argument', 'loc': ('banana',), 'msg': 'Unexpected keyword argument', 'input': 5}, |
| 506 | ] |
| 507 | |
| 508 | with pytest.raises(ValidationError) as exc_info: |
| 509 | foo(1, 2, 3) |
| 510 | |
| 511 | # insert_assert(exc_info.value.errors(include_url=False)) |
| 512 | assert exc_info.value.errors(include_url=False) == [ |
| 513 | {'type': 'unexpected_positional_argument', 'loc': (2,), 'msg': 'Unexpected positional argument', 'input': 3} |
| 514 | ] |
| 515 | |
| 516 | |
| 517 | def test_async(): |