33from rest_framework import serializers
44from rest_framework .exceptions import ValidationError
55
6+
67class TestSimpleBoundField :
78 def test_empty_bound_field (self ):
89 class ExampleSerializer (serializers .Serializer ):
@@ -212,15 +213,9 @@ class ExampleSerializer(serializers.Serializer):
212213 assert rendered_packed == expected_packed
213214
214215 def test_child_bound_field_after_parent_validation_error (self ):
215- """
216- After a parent-level ValidationError on a nested serializer field,
217- child BoundFields should remain accessible and receive a mapping
218- for `errors` so the Browsable API can render safely.
219-
220- Regression test for #4073.
221- """
222216 class ChildSerializer (serializers .Serializer ):
223217 value = serializers .CharField ()
218+
224219 class ParentSerializer (serializers .Serializer ):
225220 nested = ChildSerializer ()
226221
@@ -233,17 +228,9 @@ def validate_nested(self, nested):
233228
234229 # Parent-level error is a list (current problematic case)
235230 assert serializer .errors ["nested" ] == ["parent-level nested error" ]
236-
237- # Access nested bound field
238231 parent_bound = serializer ["nested" ]
239-
240- # Access child bound field – should not raise
241232 child_bound = parent_bound ["value" ]
242-
243- # Core contract: errors must be a mapping, not None or list
244233 assert isinstance (child_bound .errors , dict )
245-
246- # Sanity checks
247234 assert child_bound .value == "ignored"
248235 assert child_bound .name == "nested.value"
249236
0 commit comments