@@ -138,6 +138,7 @@ def test_partial_typed_dict():
138138
139139 assert v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 13 }) == snapshot (IsStrictDict (a = 11 , b = 12 , c = 13 ))
140140 assert v .validate_python ({'a' : 11 , 'c' : 13 , 'b' : '12' }) == snapshot (IsStrictDict (a = 11 , b = 12 , c = 13 ))
141+ assert v .validate_python (MyMapping ({'a' : 11 , 'c' : 13 , 'b' : '12' })) == snapshot (IsStrictDict (a = 11 , b = 12 , c = 13 ))
141142
142143 assert v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 13 }, allow_partial = True ) == snapshot ({'a' : 11 , 'b' : 12 , 'c' : 13 })
143144 with pytest .raises (ValidationError ) as exc_info :
@@ -154,6 +155,9 @@ def test_partial_typed_dict():
154155 ]
155156 )
156157 assert v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 1 }, allow_partial = True ) == snapshot (IsStrictDict (a = 11 , b = 12 ))
158+ assert v .validate_python (MyMapping ({'a' : 11 , 'b' : '12' , 'c' : 1 }), allow_partial = True ) == snapshot (
159+ IsStrictDict (a = 11 , b = 12 )
160+ )
157161 assert v .validate_python ({'a' : 11 , 'c' : 13 , 'b' : 1 }, allow_partial = True ) == snapshot (IsStrictDict (a = 11 , c = 13 ))
158162 with pytest .raises (ValidationError ) as exc_info :
159163 v .validate_python ({'a' : 11 , 'c' : 1 , 'b' : 12 }, allow_partial = True )
@@ -202,8 +206,11 @@ def test_non_partial_typed_dict():
202206 assert v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 13 }) == snapshot ({'a' : 11 , 'b' : 12 , 'c' : 13 })
203207 with pytest .raises (ValidationError , match = 'Input should be greater than 10' ):
204208 v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 1 })
205- with pytest .raises (ValidationError , match = 'Input should be greater than 10' ):
206- v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 1 }, allow_partial = False )
209+ assert v .validate_python ({'a' : 11 , 'b' : '12' , 'c' : 1 }, allow_partial = True ) == snapshot ({'a' : 11 , 'b' : 12 })
210+ with pytest .raises (ValidationError , match = r'b\s+Field required' ):
211+ v .validate_python ({'a' : 11 , 'c' : 12 }, allow_partial = True )
212+ with pytest .raises (ValidationError , match = r'b\s+Input should be greater than 10' ):
213+ v .validate_python ({'a' : 11 , 'c' : 12 , 'b' : 1 }, allow_partial = True )
207214
208215
209216def test_double_nested ():
0 commit comments