def test_formatted_decimal_field():
 class TestModelForm(ModelForm, ):
  class Meta:
   model = Product
   fields = ['width']
 values = ['0E-9', '0E-30', '1E-9', '123E-10', '-123E-10', '1.12345666666666E20']
 for value in values:
  product = Product(width=Decimal(value))
  form = TestModelForm(instance=product)
  rendered_form = force_text(form)
  rendered_value = re.search('value="(.*?)"', rendered_form).group(1)
  rendered_step = re.search('step="(.*?)"', rendered_form).group(1)
  assert (rendered_value and ('E' not in rendered_value))
  assert (rendered_step and ('E' not in rendered_step))
 large_value = '1.23E-10000'
 product = Product(width=Decimal(large_value))
 with pytest.raises(ValueError):
  form = TestModelForm(instance=product)

def test_formatted_decimal_field ( ) : class TestModelForm ( ModelForm , ) : class Meta : model = Product fields = [ 'width' ] values = [ '0E-9' , '0E-30' , '1E-9' , '123E-10' , '-123E-10' , '1.12345666666666E20' ] for value in values : product = Product ( width = Decimal ( value ) ) form = TestModelForm ( instance = product ) rendered_form = force_text ( form ) rendered_value = re . search ( 'value="(.*?)"' , rendered_form ) . group ( 1 ) rendered_step = re . search ( 'step="(.*?)"' , rendered_form ) . group ( 1 ) assert ( rendered_value and ( 'E' not in rendered_value ) ) assert ( rendered_step and ( 'E' not in rendered_step ) ) large_value = '1.23E-10000' product = Product ( width = Decimal ( large_value ) ) with pytest . raises ( ValueError ) : form = TestModelForm ( instance = product )
test that formatteddecimalfield doesnt return value in scientific notation .