Skip to content

Commit ed2bf05

Browse files
committed
fix other test
1 parent 2696529 commit ed2bf05

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

tests/serializers/test_model.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,26 +1084,27 @@ class Model:
10841084

10851085

10861086
def test_no_warn_on_exclude() -> None:
1087-
warnings.simplefilter('error')
1088-
1089-
s = SchemaSerializer(
1090-
core_schema.model_schema(
1091-
BasicModel,
1092-
core_schema.model_fields_schema(
1093-
{
1094-
'a': core_schema.model_field(core_schema.int_schema()),
1095-
'b': core_schema.model_field(core_schema.int_schema()),
1096-
}
1097-
),
1087+
with warnings.catch_warnings():
1088+
warnings.simplefilter('error')
1089+
1090+
s = SchemaSerializer(
1091+
core_schema.model_schema(
1092+
BasicModel,
1093+
core_schema.model_fields_schema(
1094+
{
1095+
'a': core_schema.model_field(core_schema.int_schema()),
1096+
'b': core_schema.model_field(core_schema.int_schema()),
1097+
}
1098+
),
1099+
)
10981100
)
1099-
)
11001101

1101-
value = BasicModel(a=0, b=1)
1102-
assert s.to_python(value, exclude={'b'}) == {'a': 0}
1103-
assert s.to_python(value, mode='json', exclude={'b'}) == {'a': 0}
1102+
value = BasicModel(a=0, b=1)
1103+
assert s.to_python(value, exclude={'b'}) == {'a': 0}
1104+
assert s.to_python(value, mode='json', exclude={'b'}) == {'a': 0}
11041105

11051106

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

0 commit comments

Comments
 (0)