MCPcopy
hub / github.com/pydantic/pydantic / test_str

Function test_str

pydantic-core/tests/test_json.py:49–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48
49def test_str():
50 s = SchemaValidator(core_schema.str_schema())
51 assert s.validate_json('"foobar"') == 'foobar'
52 with pytest.raises(ValidationError, match=r'Input should be a valid string \[type=string_type,'):
53 s.validate_json('false')
54 with pytest.raises(ValidationError, match=r'Input should be a valid string \[type=string_type,'):
55 s.validate_json('123')
56
57
58def test_bytes():

Callers

nothing calls this directly

Calls 2

str_schemaMethod · 0.80
validate_jsonMethod · 0.45

Tested by

no test coverage detected