MCPcopy
hub / github.com/pydantic/pydantic / test_wrap

Function test_wrap

pydantic-core/tests/test_validation_context.py:54–62  ·  view source on GitHub ↗
(py_and_json: PyAndJson)

Source from the content-addressed store, hash-verified

52
53
54def test_wrap(py_and_json: PyAndJson):
55 def f(input_value, validator, info):
56 return validator(input_value) + f'| context: {info.context}'
57
58 v = py_and_json(core_schema.with_info_wrap_validator_function(f, core_schema.str_schema()))
59
60 assert v.validate_test('foobar') == 'foobar| context: None'
61 assert v.validate_test('foobar', None, {1: 10}) == 'foobar| context: {1: 10}'
62 assert v.validate_test('foobar', None, 'frogspawn') == 'foobar| context: frogspawn'
63
64
65def test_isinstance(py_and_json: PyAndJson):

Callers

nothing calls this directly

Calls 3

py_and_jsonFunction · 0.85
str_schemaMethod · 0.80
validate_testMethod · 0.80

Tested by

no test coverage detected