Exemple #1
0
 def test_specific(self):
     """Test using a specific plural."""
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other|12=dozen}}',
                              {'foo': 42}), 'other')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other|12=dozen}}',
                              {'foo': 12}), 'dozen')
 def test_specific(self):
     """Test using a specific plural."""
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other|12=dozen}}',
                              {'foo': 42}),
         'other')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other|12=dozen}}',
                              {'foo': 12}),
         'dozen')
Exemple #3
0
 def test_standard(self):
     """Test default usage using a dict and no specific plurals."""
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other}}',
                              {'foo': 42}), 'other')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other}}', {'foo': 1}),
         'one')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other}}', {'foo': 0}),
         'other')
 def test_standard(self):
     """Test default usage using a dict and no specific plurals."""
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other}}', {'foo': 42}),
         'other')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other}}', {'foo': 1}),
         'one')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|other}}', {'foo': 0}),
         'other')
Exemple #5
0
 def test_empty_fields(self):
     """Test default usage using a dict and no specific plurals."""
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo||other}}', {'foo': 42}),
         'other')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo||other}}', {'foo': 1}),
         '')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|}}', {'foo': 1}),
         'one')
     with self.assertRaises(IndexError):
         i18n._extract_plural('en', '{{PLURAL:foo|one}}', {'foo': 0})
Exemple #6
0
 def test_empty_fields(self):
     """Test default usage using a dict and no specific plurals."""
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo||other}}', {'foo': 42}),
         'other')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo||other}}', {'foo': 1}),
         '')
     self.assertEqual(
         i18n._extract_plural('en', '{{PLURAL:foo|one|}}', {'foo': 1}),
         'one')
     with self.assertRaises(IndexError):
         i18n._extract_plural('en', '{{PLURAL:foo|one}}', {'foo': 0})
Exemple #7
0
 def test_less(self):
     """Test the number of plurals are less than expected."""
     test = [(0, 2), (1, 0), (2, 1), (3, 2), (4, 2), (7, 2), (8, 3)]
     for num, result in test:
         self.assertEqual(
             i18n._extract_plural('cy', '{{PLURAL:num|0|1}}', {'num': num}),
             str(min(result, 1)))
Exemple #8
0
 def test_more(self):
     """Test the number of plurals are more than expected."""
     test = [(0, 2), (1, 0), (2, 1), (3, 2), (4, 2), (7, 2), (8, 3)]
     for num, result in test:
         self.assertEqual(
             i18n._extract_plural('cy', '{{PLURAL:num|0|1|2|3|4|5}}',
                                  {'num': num}), str(result))
Exemple #9
0
    def test_empty_fields(self):
        """Test default usage using a dict and no specific plurals."""
        self.assertEqual(
            i18n._extract_plural('en', '{{PLURAL:foo||other}}', {'foo': 42}),
            'other')
        self.assertEqual(
            i18n._extract_plural('en', '{{PLURAL:foo||other}}', {'foo': 1}),
            '')
        self.assertEqual(
            i18n._extract_plural('en', '{{PLURAL:foo|one|}}', {'foo': 1}),
            'one')

        # two variants expected but only one given
        self.assertEqual(
            i18n._extract_plural('en', '{{PLURAL:foo|one}}', {'foo': 0}),
            'one')