          @staticmethod
          def localize(value, is_dst):
              raise pytz.InvalidTimeError()
  
          def __str__(self):
              return 'America/New_York'
  
      field = serializers.DateTimeField(default_timezone=MockTimezone())
  
  
  @patch('rest_framework.utils.timezone.datetime_ambiguous', return_value=True)
 
</s> remove     class MockTimezone(pytz.BaseTzInfo):
        @staticmethod
        def localize(value, is_dst):
            raise pytz.InvalidTimeError()
 </s> add     if pytz:
        class MockTimezone(pytz.BaseTzInfo):
            @staticmethod
            def localize(value, is_dst):
                raise pytz.InvalidTimeError() </s> remove     field = serializers.DateTimeField(default_timezone=MockTimezone())
 </s> add         field = serializers.DateTimeField(default_timezone=MockTimezone()) </s> remove             except InvalidTimeError:
                self.fail('make_aware', timezone=field_timezone)
 </s> add             except Exception as e:
                if pytz and isinstance(e, pytz.exceptions.InvalidTimeError):
                    self.fail('make_aware', timezone=field_timezone)
                raise e </s> remove import pytz
 </s> add try:
    import pytz
except ImportError:
    pytz = None
 </s> remove from pytz.exceptions import InvalidTimeError
 </s> add try:
    import pytz
except ImportError:
    pytz = None
            def __str__(self):
                return 'America/New_York'
          @staticmethod
          def localize(value, is_dst):
              raise pytz.InvalidTimeError()
  
            def __str__(self):
                return 'America/New_York'
            def __str__(self):
                return 'America/New_York'
  
      field = serializers.DateTimeField(default_timezone=MockTimezone())
  
  
  @patch('rest_framework.utils.timezone.datetime_ambiguous', return_value=True)
keep keep keep keep replace replace keep keep keep keep keep
 remove dependency on pytz (#8984)

* remove pytz

* Revert "remove pytz"

This reverts commit 393609dfaadbc4d82f760e6e4df8a6de6de24f9b.

* remove pytz, more subtly 
tests/test_fields.py