Ticket #11783: humanize_ordinal_TypeError_with_tests.diff
File humanize_ordinal_TypeError_with_tests.diff, 1.3 KB (added by , 15 years ago) |
---|
-
django/contrib/humanize/templatetags/humanize.py
14 14 """ 15 15 try: 16 16 value = int(value) 17 except ValueError:17 except (TypeError, ValueError): 18 18 return value 19 19 t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th')) 20 20 if value % 100 in (11, 12, 13): # special case -
tests/regressiontests/humanize/tests.py
22 22 def test_ordinal(self): 23 23 test_list = ('1','2','3','4','11','12', 24 24 '13','101','102','103','111', 25 'something else' )25 'something else', None) 26 26 result_list = ('1st', '2nd', '3rd', '4th', '11th', 27 27 '12th', '13th', '101st', '102nd', '103rd', 28 '111th', 'something else' )28 '111th', 'something else', None) 29 29 30 30 self.humanize_tester(test_list, result_list, 'ordinal') 31 31