Skip to content

Commit aa91a11

Browse files
[3.12] gh-130655: Increase test coverage of gettext._expand_lang() (GH-130656) (GH-130672)
(cherry picked from commit 24c52cb) Co-authored-by: Tomas R <tomas.roun8@gmail.com>
1 parent 500ea3b commit aa91a11

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Lib/test/test_gettext.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import base64
33
import gettext
44
import unittest
5+
import unittest.mock
56
from functools import partial
67

78
from test import support
@@ -739,6 +740,32 @@ def test_cache(self):
739740
self.assertEqual(t.__class__, DummyGNUTranslations)
740741

741742

743+
class ExpandLangTestCase(unittest.TestCase):
744+
def test_expand_lang(self):
745+
# Test all combinations of territory, charset and
746+
# modifier (locale extension)
747+
locales = {
748+
'cs': ['cs'],
749+
'cs_CZ': ['cs_CZ', 'cs'],
750+
'cs.ISO8859-2': ['cs.ISO8859-2', 'cs'],
751+
'cs@euro': ['cs@euro', 'cs'],
752+
'cs_CZ.ISO8859-2': ['cs_CZ.ISO8859-2', 'cs_CZ', 'cs.ISO8859-2',
753+
'cs'],
754+
'cs_CZ@euro': ['cs_CZ@euro', 'cs@euro', 'cs_CZ', 'cs'],
755+
'cs.ISO8859-2@euro': ['cs.ISO8859-2@euro', 'cs@euro',
756+
'cs.ISO8859-2', 'cs'],
757+
'cs_CZ.ISO8859-2@euro': ['cs_CZ.ISO8859-2@euro', 'cs_CZ@euro',
758+
'cs.ISO8859-2@euro', 'cs@euro',
759+
'cs_CZ.ISO8859-2', 'cs_CZ',
760+
'cs.ISO8859-2', 'cs'],
761+
}
762+
for locale, expanded in locales.items():
763+
with self.subTest(locale=locale):
764+
with unittest.mock.patch("locale.normalize",
765+
return_value=locale):
766+
self.assertEqual(gettext._expand_lang(locale), expanded)
767+
768+
742769
class MiscTestCase(unittest.TestCase):
743770
def test__all__(self):
744771
support.check__all__(self, gettext,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy