MCPcopy
hub / github.com/pydantic/pydantic / test_after

Function test_after

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

Source from the content-addressed store, hash-verified

6
7
8def test_after(py_and_json: PyAndJson):
9 def f(input_value, info):
10 return input_value + f'| context: {info.context}'
11
12 v = py_and_json(core_schema.with_info_after_validator_function(f, core_schema.str_schema()))
13
14 assert v.validate_test('foobar') == 'foobar| context: None'
15 assert v.validate_test('foobar', None, {1: 10}) == 'foobar| context: {1: 10}'
16 assert v.validate_test('foobar', None, 'frogspawn') == 'foobar| context: frogspawn'
17
18
19def test_mutable_context(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