mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 13:00:12 +03:00
Add test for disabling declared fields on child
This commit is contained in:
parent
b52de0a871
commit
a41a1e466d
|
@ -413,3 +413,20 @@ class Test4606Regression:
|
||||||
serializer = self.Serializer(data=[{"name": "liz"}], many=True)
|
serializer = self.Serializer(data=[{"name": "liz"}], many=True)
|
||||||
with pytest.raises(serializers.ValidationError):
|
with pytest.raises(serializers.ValidationError):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDeclaredFieldInheritance:
|
||||||
|
def test_declared_field_disabling(self):
|
||||||
|
class Parent(serializers.Serializer):
|
||||||
|
f1 = serializers.CharField()
|
||||||
|
f2 = serializers.CharField()
|
||||||
|
|
||||||
|
class Child(Parent):
|
||||||
|
f1 = None
|
||||||
|
|
||||||
|
class Grandchild(Child):
|
||||||
|
pass
|
||||||
|
|
||||||
|
assert len(Parent._declared_fields) == 2
|
||||||
|
assert len(Child._declared_fields) == 1
|
||||||
|
assert len(Grandchild._declared_fields) == 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user