  
  
  class TestDecimalField(FieldValues):
      """
      Valid and invalid values for `DecimalField`.
      """
      valid_inputs = {
          '12.3': Decimal('12.3'),
 
</s> remove         'max_string_length': _('String value too large.')
 </s> add         'max_string_length': _('String value too large.'),
        'overflow': _('Integer value too large to convert to float')
class TestFloatFieldOverFlowError(TestCase):
    def test_overflow_error_float_field(self):
        field = serializers.FloatField()
        with pytest.raises(serializers.ValidationError) as exec_info:
            field.to_internal_value(data=math.factorial(171))
        assert "Integer value too large to convert to float" in str(exec_info.value.detail)


  
  
class TestFloatFieldOverFlowError(TestCase):
    def test_overflow_error_float_field(self):
        field = serializers.FloatField()
        with pytest.raises(serializers.ValidationError) as exec_info:
            field.to_internal_value(data=math.factorial(171))
        assert "Integer value too large to convert to float" in str(exec_info.value.detail)


  class TestDecimalField(FieldValues):
      """
      Valid and invalid values for `DecimalField`.
      """
      valid_inputs = {
          '12.3': Decimal('12.3'),
keep add keep keep keep keep keep keep
 FloatField will crash if the input is a number that is too big (#8725)

* FloatField will crash if the input is a number that is too big

* Added Unit test for float field overflow error catch

* Removed random import

* Removed additional imported ValidationError

* Update rest_framework/fields.py

* Update tests/test_fields.py

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com> 
tests/test_fields.py