Issue #28563: Make plural form selection more lenient and accepting

non-integer numbers.  Django tests depend on this.
This commit is contained in:
Serhiy Storchaka 2016-11-14 19:25:56 +02:00
commit 5ca92ab3d2
2 changed files with 20 additions and 8 deletions

View file

@ -371,12 +371,16 @@ class PluralFormsTestCase(GettextBaseTest):
self.assertRaises(ZeroDivisionError, f, 0)
def test_plural_number(self):
f = gettext.c2py('1')
self.assertEqual(f(1), 1)
self.assertRaises(ValueError, f, 1.0)
self.assertRaises(ValueError, f, '1')
self.assertRaises(ValueError, f, [])
self.assertRaises(ValueError, f, object())
f = gettext.c2py('n != 1')
self.assertEqual(f(1), 0)
self.assertEqual(f(2), 1)
self.assertEqual(f(1.0), 0)
self.assertEqual(f(2.0), 1)
self.assertEqual(f(1.1), 1)
self.assertRaises(TypeError, f, '2')
self.assertRaises(TypeError, f, b'2')
self.assertRaises(TypeError, f, [])
self.assertRaises(TypeError, f, object())
class GNUTranslationParsingTest(GettextBaseTest):