Ticket #8898: 8898-DateTimeField-r8983.diff

File 8898-DateTimeField-r8983.diff, 2.1 KB (added by Tai Lee, 16 years ago)

Update tests to match None return value.

  • django/forms/fields.py

     
    379379        if isinstance(value, list):
    380380            # Input comes from a SplitDateTimeWidget, for example. So, it's two
    381381            # components: date and time.
     382            if not [v for v in value if v not in EMPTY_VALUES]:
     383                if self.required:
     384                    raise ValidationError(self.error_messages['required'])
     385                return None
    382386            if len(value) != 2:
    383387                raise ValidationError(self.error_messages['invalid'])
    384388            value = '%s %s' % tuple(value)
  • tests/regressiontests/forms/fields.py

     
    619619>>> repr(f.clean(''))
    620620'None'
    621621
     622Regression test for #8898.
     623>>> f = DateTimeField(widget=SplitDateTimeWidget)
     624>>> f.clean(['', ''])
     625Traceback (most recent call last):
     626...
     627ValidationError: [u'This field is required.']
     628>>> f = DateTimeField(required=False, widget=SplitDateTimeWidget)
     629>>> repr(f.clean(['', '']))
     630'None'
     631
    622632# RegexField ##################################################################
    623633
    624634>>> f = RegexField('^\d[A-F]\d$')
  • AUTHORS

     
    239239    Eugene Lazutkin <http://lazutkin.com/blog/>
    240240    lcordier@point45.com
    241241    Jeong-Min Lee <falsetru@gmail.com>
     242    Tai Lee <real.human@mrmachine.net>
    242243    Jannis Leidel <jl@websushi.org>
    243244    Christopher Lenz <http://www.cmlenz.net/>
    244245    lerouxb@gmail.com
     
    278279    Aljosa Mohorovic <aljosa.mohorovic@gmail.com>
    279280    Ramiro Morales <rm0@gmx.net>
    280281    Eric Moritz <http://eric.themoritzfamily.com/>
    281     mrmachine <real.human@mrmachine.net>
    282282    Robin Munn <http://www.geekforgod.com/>
    283283    James Murty
    284284    msundstr
Back to Top