|
11 | 11 |
|
12 | 12 | from pydantic_core import SchemaSerializer, SchemaValidator, ValidationError, validate_core_schema
|
13 | 13 |
|
14 |
| -from .complete_schema import input_data_lax, input_data_strict, input_data_wrong, schema |
| 14 | +from .complete_schema import input_data_lax, input_data_strict, input_data_wrong, schema, wrap_schema_in_root_model |
15 | 15 |
|
16 | 16 |
|
17 | 17 | def test_complete_valid():
|
@@ -99,6 +99,12 @@ def test_complete_core_strict(benchmark):
|
99 | 99 | benchmark(v.validate_python, input_data_strict())
|
100 | 100 |
|
101 | 101 |
|
| 102 | +@pytest.mark.benchmark(group='complete') |
| 103 | +def test_complete_core_root(benchmark): |
| 104 | + v = SchemaValidator(validate_core_schema(wrap_schema_in_root_model(schema()))) |
| 105 | + benchmark(v.validate_python, {'root': input_data_lax()}) |
| 106 | + |
| 107 | + |
102 | 108 | @pytest.mark.benchmark(group='complete-to-python')
|
103 | 109 | def test_complete_core_serializer_to_python(benchmark):
|
104 | 110 | core_schema = validate_core_schema(schema())
|
@@ -160,6 +166,13 @@ def test_complete_core_json(benchmark):
|
160 | 166 | benchmark(v.validate_json, json_data)
|
161 | 167 |
|
162 | 168 |
|
| 169 | +@pytest.mark.benchmark(group='complete-json') |
| 170 | +def test_complete_core_root_json(benchmark): |
| 171 | + v = SchemaValidator(validate_core_schema(wrap_schema_in_root_model(schema()))) |
| 172 | + json_data = json.dumps({'root': input_data_lax()}, default=default_json_encoder) |
| 173 | + benchmark(v.validate_json, json_data) |
| 174 | + |
| 175 | + |
163 | 176 | @pytest.mark.benchmark(group='build')
|
164 | 177 | def test_build_schema(benchmark):
|
165 | 178 | lax_schema = schema()
|
|
0 commit comments