File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -612,3 +612,21 @@ def test_pydantic_serialization_unexpected_value():
612
612
v = PydanticSerializationUnexpectedValue ()
613
613
assert str (v ) == 'Unexpected Value'
614
614
assert repr (v ) == 'PydanticSerializationUnexpectedValue(Unexpected Value)'
615
+
616
+
617
+ def test_function_after_preserves_wrapped_serialization ():
618
+ def f (value , _info ):
619
+ return value
620
+
621
+ s = SchemaSerializer (core_schema .general_after_validator_function (f , core_schema .int_schema ()))
622
+ with pytest .warns (UserWarning , match = 'Expected `int` but got `str` - serialized value may not be as expected' ):
623
+ assert s .to_python ('abc' ) == 'abc'
624
+
625
+
626
+ def test_function_wrap_preserves_wrapped_serialization ():
627
+ def f (value , handler , _info ):
628
+ return handler (value )
629
+
630
+ s = SchemaSerializer (core_schema .general_wrap_validator_function (f , core_schema .int_schema ()))
631
+ with pytest .warns (UserWarning , match = 'Expected `int` but got `str` - serialized value may not be as expected' ):
632
+ assert s .to_python ('abc' ) == 'abc'
You can’t perform that action at this time.
0 commit comments