  import pytest
  from django.http import QueryDict
  from django.test import TestCase, override_settings
  from django.utils import six
  from django.utils.timezone import pytz, utc
  
  import rest_framework
  from rest_framework import serializers
  from rest_framework.fields import is_simple_callable
  
 
</s> remove from rest_framework import serializers
 </s> add from rest_framework import compat, serializers </s> remove     get_remote_field, unicode_repr, unicode_to_repr, value_from_object
 </s> add     InvalidTimeError, get_remote_field, unicode_repr, unicode_to_repr,
    value_from_object </s> remove     field = serializers.DateTimeField(default_timezone=pytz.timezone('America/New_York'))
 </s> add     class MockTimezone:
        @staticmethod
        def localize(value, is_dst):
            raise compat.InvalidTimeError()

        def __str__(self):
            return 'America/New_York'

    field = serializers.DateTimeField(default_timezone=MockTimezone()) </s> remove             except Exception:
 </s> add             except InvalidTimeError:
from django.utils.timezone import utc
  import pytest
  from django.http import QueryDict
  from django.test import TestCase, override_settings
  from django.utils import six
from django.utils.timezone import utc
  
  import rest_framework
  from rest_framework import serializers
  from rest_framework.fields import is_simple_callable
  
keep keep keep keep replace keep keep keep keep keep
 Added pytz exception in compat module.
Mock pytz.timezone localize in tests.
Ref: #4986 
tests/test_fields.py