Ticket #11783: humanize_ordinal_TypeError_with_tests.diff

File humanize_ordinal_TypeError_with_tests.diff, 1.3 KB (added by punteney, 5 years ago)

Updated diff with test case

  • django/contrib/humanize/templatetags/humanize.py

     
    1414    """
    1515    try:
    1616        value = int(value)
    17     except ValueError:
     17    except (TypeError, ValueError):
    1818        return value
    1919    t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
    2020    if value % 100 in (11, 12, 13): # special case
  • tests/regressiontests/humanize/tests.py

     
    2222    def test_ordinal(self):
    2323        test_list = ('1','2','3','4','11','12',
    2424                     '13','101','102','103','111',
    25                      'something else')
     25                     'something else', None)
    2626        result_list = ('1st', '2nd', '3rd', '4th', '11th',
    2727                       '12th', '13th', '101st', '102nd', '103rd',
    28                        '111th', 'something else')
     28                       '111th', 'something else', None)
    2929
    3030        self.humanize_tester(test_list, result_list, 'ordinal')
    3131
Back to Top