Commit c17337ed authored by Michal Čihař's avatar Michal Čihař

Test coverage for lang.get_plural_label

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 0afc18aa
...@@ -397,7 +397,7 @@ class Language(models.Model, PercentMixin): ...@@ -397,7 +397,7 @@ class Language(models.Model, PercentMixin):
except (IndexError, KeyError): except (IndexError, KeyError):
if idx == 0: if idx == 0:
return _('Singular') return _('Singular')
elif idx == 0: elif idx == 1:
return _('Plural') return _('Plural')
return _('Plural form %d') % idx return _('Plural form %d') % idx
......
...@@ -207,6 +207,19 @@ class LanguagesTest(TestCase): ...@@ -207,6 +207,19 @@ class LanguagesTest(TestCase):
'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;'
) )
def test_plural_labels(self):
lang = Language.objects.get(code='cs')
self.assertEqual(lang.get_plural_label(0), 'One')
self.assertEqual(lang.get_plural_label(1), 'Few')
self.assertEqual(lang.get_plural_label(2), 'Other')
def test_plural_labels_invalid(self):
lang = Language.objects.get(code='cs')
lang.plural_type = -1
self.assertEqual(lang.get_plural_label(0), 'Singular')
self.assertEqual(lang.get_plural_label(1), 'Plural')
self.assertEqual(lang.get_plural_label(2), 'Plural form 2')
class CommandTest(TestCase): class CommandTest(TestCase):
''' '''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment