mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
Fix framework deprecation warning in test
This commit is contained in:
parent
d09a612863
commit
91563bab6e
|
@ -565,11 +565,10 @@ class TestCreateOnlyDefault:
|
||||||
on the callable if possible
|
on the callable if possible
|
||||||
"""
|
"""
|
||||||
class TestCallableDefault:
|
class TestCallableDefault:
|
||||||
def set_context(self, serializer_field):
|
requires_context = True
|
||||||
self.field = serializer_field
|
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self, field=None):
|
||||||
return "success" if hasattr(self, 'field') else "failure"
|
return "success" if field is not None else "failure"
|
||||||
|
|
||||||
class TestSerializer(serializers.Serializer):
|
class TestSerializer(serializers.Serializer):
|
||||||
context_set = serializers.CharField(default=serializers.CreateOnlyDefault(TestCallableDefault()))
|
context_set = serializers.CharField(default=serializers.CreateOnlyDefault(TestCallableDefault()))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user