mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Issue #28563: Make plural form selection more lenient and accepting
non-integer numbers. Django tests depend on this.
This commit is contained in:
commit
5ca92ab3d2
2 changed files with 20 additions and 8 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue