Permalink
Browse files

Fixed #22798 -- `pluralize()` now adds plural_suffix for any `1 < d < 2`

Thanks Odd_Bloke for the report.
  • Loading branch information...
1 parent f97c53c commit 868ff4e37c1e4cfaf7283496c24f6e711ad66005 @mmardini mmardini committed with timgraham Jun 10, 2014
Showing with 6 additions and 1 deletion.
  1. +1 −1 django/template/defaultfilters.py
  2. +5 −0 tests/defaultfilters/tests.py
@@ -934,7 +934,7 @@ def pluralize(value, arg='s'):
singular_suffix, plural_suffix = bits[:2]
try:
- if int(value) != 1:
+ if float(value) != 1:
return plural_suffix
except ValueError: # Invalid string that's not a number.
pass
@@ -654,6 +654,11 @@ def test_pluralize(self):
self.assertEqual(pluralize(1), '')
self.assertEqual(pluralize(0), 's')
self.assertEqual(pluralize(2), 's')
+
+ # Ticket #22798
+ self.assertEqual(pluralize(0.5), 's')
+ self.assertEqual(pluralize(1.5), 's')
+
self.assertEqual(pluralize(decimal.Decimal(1)), '')
self.assertEqual(pluralize(decimal.Decimal(0)), 's')
self.assertEqual(pluralize(decimal.Decimal(2)), 's')

0 comments on commit 868ff4e

Please sign in to comment.