|
8 | 8 | import pytest
|
9 | 9 | from dirty_equals import FunctionCheck, HasRepr, IsStr
|
10 | 10 |
|
11 |
| -from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema |
| 11 | +from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError |
12 | 12 |
|
13 | 13 | from ..conftest import Err, PyAndJson
|
14 | 14 |
|
@@ -1436,26 +1436,3 @@ def test_frozen_field():
|
1436 | 1436 | assert exc_info.value.errors() == [
|
1437 | 1437 | {'type': 'frozen', 'loc': ('is_developer',), 'msg': 'Field is frozen', 'input': False}
|
1438 | 1438 | ]
|
1439 |
| - |
1440 |
| - |
1441 |
| -def test_field_before_function(): |
1442 |
| - """A field cannot be required and have a default value""" |
1443 |
| - |
1444 |
| - def f(v: str, info: core_schema.ModelFieldValidationInfo) -> str: |
1445 |
| - assert v == 'hello' |
1446 |
| - assert info.data == {'x': 'hello'} |
1447 |
| - assert info.field_name == 'x' |
1448 |
| - return 'hello world!' |
1449 |
| - |
1450 |
| - v = SchemaValidator( |
1451 |
| - core_schema.typed_dict_schema( |
1452 |
| - { |
1453 |
| - 'a': core_schema.typed_dict_field(core_schema.int_schema()), |
1454 |
| - 'c': core_schema.typed_dict_field( |
1455 |
| - core_schema.field_before_validation_function(f, core_schema.str_schema()) |
1456 |
| - ), |
1457 |
| - } |
1458 |
| - ) |
1459 |
| - ) |
1460 |
| - |
1461 |
| - assert v.validate_python({'a': 1, 'c': 'hello'}) == {'a': 1, 'c': 'hello world!'} |
0 commit comments