Ticket #5355: 5355.diff

File 5355.diff, 1.3 KB (added by Philippe Raoult, 17 years ago)

correct patch with regression tests

  • django/newforms/fields.py

     
    192192        super(DecimalField, self).clean(value)
    193193        if not self.required and value in EMPTY_VALUES:
    194194            return None
    195         value = value.strip()
    196195        try:
    197196            value = Decimal(value)
    198197        except DecimalException:
  • tests/regressiontests/forms/tests.py

     
    961961Traceback (most recent call last):
    962962...
    963963ValidationError: [u'Enter a whole number.']
     964>>> f.clean(42)
     96542
     966>>> f.clean(3.14)
     9673
    964968>>> f.clean('1 ')
    9659691
    966970>>> f.clean(' 1')
     
    1084108823.0
    10851089>>> f.clean('3.14')
    108610903.1400000000000001
     1091>>> f.clean(3.14)
     10923.1400000000000001
     1093>>> f.clean(42)
     109442.0
    10871095>>> f.clean('a')
    10881096Traceback (most recent call last):
    10891097...
     
    11421150Decimal("23")
    11431151>>> f.clean('3.14')
    11441152Decimal("3.14")
     1153>>> f.clean(3.14)
     1154Decimal("3.14")
     1155>>> f.clean(Decimal('3.14'))
     1156Decimal("3.14")
    11451157>>> f.clean('a')
    11461158Traceback (most recent call last):
    11471159...
Back to Top