mirror of
https://github.com/encode/django-rest-framework.git
synced 2026-01-09 18:20:55 +03:00
chore: apply pre-commit formatting
This commit is contained in:
parent
3fc1c73168
commit
e9aaf0649b
|
|
@ -144,7 +144,6 @@ class NestedBoundField(BoundField):
|
|||
return JSONBoundField(field, value, error, prefix=self.name + '.')
|
||||
return BoundField(field, value, error, prefix=self.name + '.')
|
||||
|
||||
|
||||
def as_form_field(self):
|
||||
values = {}
|
||||
for key, value in self.value.items():
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from django.http import QueryDict
|
|||
from rest_framework import serializers
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
|
||||
class TestSimpleBoundField:
|
||||
def test_empty_bound_field(self):
|
||||
class ExampleSerializer(serializers.Serializer):
|
||||
|
|
@ -212,15 +213,9 @@ class TestNestedBoundField:
|
|||
assert rendered_packed == expected_packed
|
||||
|
||||
def test_child_bound_field_after_parent_validation_error(self):
|
||||
"""
|
||||
After a parent-level ValidationError on a nested serializer field,
|
||||
child BoundFields should remain accessible and receive a mapping
|
||||
for `errors` so the Browsable API can render safely.
|
||||
|
||||
Regression test for #4073.
|
||||
"""
|
||||
class ChildSerializer(serializers.Serializer):
|
||||
value = serializers.CharField()
|
||||
|
||||
class ParentSerializer(serializers.Serializer):
|
||||
nested = ChildSerializer()
|
||||
|
||||
|
|
@ -233,17 +228,9 @@ class TestNestedBoundField:
|
|||
|
||||
# Parent-level error is a list (current problematic case)
|
||||
assert serializer.errors["nested"] == ["parent-level nested error"]
|
||||
|
||||
# Access nested bound field
|
||||
parent_bound = serializer["nested"]
|
||||
|
||||
# Access child bound field – should not raise
|
||||
child_bound = parent_bound["value"]
|
||||
|
||||
# Core contract: errors must be a mapping, not None or list
|
||||
assert isinstance(child_bound.errors, dict)
|
||||
|
||||
# Sanity checks
|
||||
assert child_bound.value == "ignored"
|
||||
assert child_bound.name == "nested.value"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user