Fix framework deprecation warning in test

This commit is contained in:
Ryan P Kilby 2019-12-04 17:00:09 -08:00
parent d09a612863
commit 91563bab6e

View File

@ -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()))