Skip to content

Commit b279824

Browse files
committed
fix tests
1 parent ed2bf05 commit b279824

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/serializers/test_model.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
import pytest
1414
from dirty_equals import IsJson
1515

16-
from pydantic_core import PydanticSerializationError, SchemaSerializer, SchemaValidator, core_schema
16+
from pydantic_core import (
17+
PydanticSerializationError,
18+
PydanticSerializationUnexpectedValue,
19+
SchemaSerializer,
20+
SchemaValidator,
21+
core_schema,
22+
)
1723

1824
from ..conftest import plain_repr
1925

@@ -1104,7 +1110,6 @@ def test_no_warn_on_exclude() -> None:
11041110
assert s.to_python(value, mode='json', exclude={'b'}) == {'a': 0}
11051111

11061112

1107-
# @pytest.mark.xfail(reason='Currently failing bc of a lack of warning, but equivalent script is passing...')
11081113
def test_warn_on_missing_field() -> None:
11091114
class AModel(BasicModel): ...
11101115

@@ -1145,9 +1150,6 @@ class BModel(BasicModel): ...
11451150
)
11461151
)
11471152

1148-
value = BasicModel(root=AModel(type='a'))
1149-
with pytest.warns(
1150-
UserWarning,
1151-
match='Expected 2 fields but got 1 for field root of type.+',
1152-
):
1153-
assert s.to_python(value) == {'root': {'type': 'a'}}
1153+
with pytest.raises(PydanticSerializationUnexpectedValue):
1154+
value = BasicModel(root=AModel(type='a'))
1155+
s.to_python(value)

0 commit comments

Comments
 (0)