MCPcopy
hub / github.com/pydantic/pydantic / test_annotated_strict

Function test_annotated_strict

tests/test_validate_call.py:852–869  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

850
851
852def test_annotated_strict():
853 @validate_call
854 def f1(x: Annotated[int, Strict()]):
855 return x
856
857 @validate_call
858 def f2(x: 'Annotated[int, Strict()]'):
859 return x
860
861 for f in (f1, f2):
862 assert f(1) == 1
863
864 with pytest.raises(ValidationError) as exc_info:
865 f('1')
866
867 assert exc_info.value.errors(include_url=False) == [
868 {'type': 'int_type', 'loc': (0,), 'msg': 'Input should be a valid integer', 'input': '1'}
869 ]
870
871
872def test_annotated_use_of_alias():

Callers

nothing calls this directly

Calls 2

fFunction · 0.70
errorsMethod · 0.45

Tested by

no test coverage detected