@@ -2894,12 +2894,11 @@ class DefinitelyUniqueSchema(Schema):
28942894 assert SchemaClass is DefinitelyUniqueSchema
28952895
28962896
2897- def test_propagate_unknown_stops_at_explicit_value_for_nested ():
2898- # PROPAGATE should traverse any "auto_unknown" values and
2899- # replace them with the "unknown" value from the parent context (schema or
2900- # load arguments)
2901- # this test makes sure that it stops when a nested field or schema has
2902- # "unknown" set explicitly (so auto_unknown=False)
2897+ def test_propagate_unknown_overrides_explicit_value_for_nested ():
2898+ # PROPAGATE should traverse any schemas and replace them with the
2899+ # "unknown" value from the parent context (schema or load arguments)
2900+ # this test makes sure that it takes precedence when a nested field
2901+ # or schema has "unknown" set explicitly
29032902
29042903 class Bottom (Schema ):
29052904 x = fields .Str ()
@@ -2923,14 +2922,13 @@ class Top(Schema):
29232922 assert result == {
29242923 "x" : "hi" ,
29252924 "y" : "bye" ,
2926- "child" : {"x" : "hi" , "y" : "bye" , "child" : {"x" : "hi" }},
2925+ "child" : {"x" : "hi" , "y" : "bye" , "child" : {"x" : "hi" , "y" : "bye" }},
29272926 }
29282927
29292928
2930- def test_propagate_unknown_stops_at_explicit_value_for_meta ():
2931- # this is the same as the above test of unknown propagation stopping where
2932- # auto_unknown=False, but it checks that this applies when `unknown` is set
2933- # by means of `Meta`
2929+ def test_propagate_unknown_overrides_explicit_value_for_meta ():
2930+ # this is the same as the above test of unknown propagation, but it checks that
2931+ # this applies when `unknown` is set by means of `Meta` as well
29342932
29352933 class Bottom (Schema ):
29362934 x = fields .Str ()
@@ -2939,25 +2937,21 @@ class Middle(Schema):
29392937 x = fields .Str ()
29402938 child = fields .Nested (Bottom )
29412939
2942- # set unknown explicitly here, so auto_unknown will be
2943- # false going into Bottom, and also set propagate to make it propagate
2944- # in this case
29452940 class Meta :
2946- unknown = EXCLUDE | PROPAGATE
2941+ unknown = EXCLUDE
29472942
29482943 class Top (Schema ):
29492944 x = fields .Str ()
29502945 child = fields .Nested (Middle )
29512946
2952- # sanity-check that auto-unknown is being set correctly
2953- assert Top ().auto_unknown
2954- assert not Top (unknown = INCLUDE | PROPAGATE ).auto_unknown
2955- assert not Middle ().auto_unknown
2956-
29572947 data = {
29582948 "x" : "hi" ,
29592949 "y" : "bye" ,
29602950 "child" : {"x" : "hi" , "y" : "bye" , "child" : {"x" : "hi" , "y" : "bye" }},
29612951 }
29622952 result = Top (unknown = INCLUDE | PROPAGATE ).load (data )
2963- assert result == {"x" : "hi" , "y" : "bye" , "child" : {"x" : "hi" , "child" : {"x" : "hi" }}}
2953+ assert result == {
2954+ "x" : "hi" ,
2955+ "y" : "bye" ,
2956+ "child" : {"x" : "hi" , "y" : "bye" , "child" : {"x" : "hi" , "y" : "bye" }},
2957+ }
0 commit comments