@@ -207,7 +207,7 @@ def append_42(value, _info):
207207 assert s .to_python ([1 , 2 , 3 ], mode = 'json' ) == [1 , 2 , 3 , 42 ]
208208 assert s .to_json ([1 , 2 , 3 ]) == b'[1,2,3,42]'
209209
210- msg = r"Expected `list\[int\]` but got `str` with value `'abc'` - serialized value may not be as expected"
210+ msg = r"Expected `list\[int\]` - serialized value may not be as expected \[input_value='abc', input_type=str\] "
211211 with pytest .warns (UserWarning , match = msg ):
212212 assert s .to_python ('abc' ) == 'abc'
213213
@@ -323,15 +323,18 @@ def test_wrong_return_type():
323323 )
324324 )
325325 with pytest .warns (
326- UserWarning , match = "Expected `int` but got `str` with value `'123'` - serialized value may not be as expected"
326+ UserWarning ,
327+ match = r"Expected `int` - serialized value may not be as expected \[input_value='123', input_type=str\]" ,
327328 ):
328329 assert s .to_python (123 ) == '123'
329330 with pytest .warns (
330- UserWarning , match = "Expected `int` but got `str` with value `'123'` - serialized value may not be as expected"
331+ UserWarning ,
332+ match = r"Expected `int` - serialized value may not be as expected \[input_value='123', input_type=str\]" ,
331333 ):
332334 assert s .to_python (123 , mode = 'json' ) == '123'
333335 with pytest .warns (
334- UserWarning , match = "Expected `int` but got `str` with value `'123'` - serialized value may not be as expected"
336+ UserWarning ,
337+ match = r"Expected `int` - serialized value may not be as expected \[input_value='123', input_type=str\]" ,
335338 ):
336339 assert s .to_json (123 ) == b'"123"'
337340
@@ -363,15 +366,18 @@ def f(value, serializer):
363366 assert s .to_python (3 , mode = 'json' ) == 'result=3'
364367 assert s .to_json (3 ) == b'"result=3"'
365368 with pytest .warns (
366- UserWarning , match = 'Expected `str` but got `int` with value `42` - serialized value may not be as expected'
369+ UserWarning ,
370+ match = r'Expected `str` - serialized value may not be as expected \[input_value=42, input_type=int\]' ,
367371 ):
368372 assert s .to_python (42 ) == 42
369373 with pytest .warns (
370- UserWarning , match = 'Expected `str` but got `int` with value `42` - serialized value may not be as expected'
374+ UserWarning ,
375+ match = r'Expected `str` - serialized value may not be as expected \[input_value=42, input_type=int\]' ,
371376 ):
372377 assert s .to_python (42 , mode = 'json' ) == 42
373378 with pytest .warns (
374- UserWarning , match = 'Expected `str` but got `int` with value `42` - serialized value may not be as expected'
379+ UserWarning ,
380+ match = r'Expected `str` - serialized value may not be as expected \[input_value=42, input_type=int\]' ,
375381 ):
376382 assert s .to_json (42 ) == b'42'
377383
@@ -624,7 +630,8 @@ def f(value, _info):
624630
625631 s = SchemaSerializer (core_schema .with_info_after_validator_function (f , core_schema .int_schema ()))
626632 with pytest .warns (
627- UserWarning , match = "Expected `int` but got `str` with value `'abc'` - serialized value may not be as expected"
633+ UserWarning ,
634+ match = r"Expected `int` - serialized value may not be as expected \[input_value='abc', input_type=str\]" ,
628635 ):
629636 assert s .to_python ('abc' ) == 'abc'
630637
@@ -635,7 +642,8 @@ def f(value, handler, _info):
635642
636643 s = SchemaSerializer (core_schema .with_info_wrap_validator_function (f , core_schema .int_schema ()))
637644 with pytest .warns (
638- UserWarning , match = "Expected `int` but got `str` with value `'abc'` - serialized value may not be as expected"
645+ UserWarning ,
646+ match = r"Expected `int` - serialized value may not be as expected \[input_value='abc', input_type=str\]" ,
639647 ):
640648 assert s .to_python ('abc' ) == 'abc'
641649
0 commit comments