https://github.com/python/cpython/commit/aa91a11c4018c83f83fa456e17373d4e30d1a7fc commit: aa91a11c4018c83f83fa456e17373d4e30d1a7fc branch: 3.12 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: serhiy-storchaka <storch...@gmail.com> date: 2025-02-28T08:58:09Z summary:
[3.12] gh-130655: Increase test coverage of gettext._expand_lang() (GH-130656) (GH-130672) (cherry picked from commit 24c52cb14c4b044154bd46bd1b2a9c37076caeb9) Co-authored-by: Tomas R <tomas.ro...@gmail.com> files: M Lib/test/test_gettext.py diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index 82f5250c6396e6..8856cf2db2099c 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -2,6 +2,7 @@ import base64 import gettext import unittest +import unittest.mock from functools import partial from test import support @@ -739,6 +740,32 @@ def test_cache(self): self.assertEqual(t.__class__, DummyGNUTranslations) +class ExpandLangTestCase(unittest.TestCase): + def test_expand_lang(self): + # Test all combinations of territory, charset and + # modifier (locale extension) + locales = { + 'cs': ['cs'], + 'cs_CZ': ['cs_CZ', 'cs'], + 'cs.ISO8859-2': ['cs.ISO8859-2', 'cs'], + 'cs@euro': ['cs@euro', 'cs'], + 'cs_CZ.ISO8859-2': ['cs_CZ.ISO8859-2', 'cs_CZ', 'cs.ISO8859-2', + 'cs'], + 'cs_CZ@euro': ['cs_CZ@euro', 'cs@euro', 'cs_CZ', 'cs'], + 'cs.ISO8859-2@euro': ['cs.ISO8859-2@euro', 'cs@euro', + 'cs.ISO8859-2', 'cs'], + 'cs_CZ.ISO8859-2@euro': ['cs_CZ.ISO8859-2@euro', 'cs_CZ@euro', + 'cs.ISO8859-2@euro', 'cs@euro', + 'cs_CZ.ISO8859-2', 'cs_CZ', + 'cs.ISO8859-2', 'cs'], + } + for locale, expanded in locales.items(): + with self.subTest(locale=locale): + with unittest.mock.patch("locale.normalize", + return_value=locale): + self.assertEqual(gettext._expand_lang(locale), expanded) + + class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, gettext, _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com