|
2 | 2 | importbase64
|
3 | 3 | importgettext
|
4 | 4 | importunittest
|
| 5 | +importunittest.mock |
5 | 6 | fromfunctoolsimportpartial
|
6 | 7 |
|
7 | 8 | fromtestimportsupport
|
@@ -739,6 +740,32 @@ def test_cache(self):
|
739 | 740 | self.assertEqual(t.__class__,DummyGNUTranslations)
|
740 | 741 |
|
741 | 742 |
|
| 743 | +classExpandLangTestCase(unittest.TestCase): |
| 744 | +deftest_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 | +forlocale,expandedinlocales.items(): |
| 763 | +withself.subTest(locale=locale): |
| 764 | +withunittest.mock.patch("locale.normalize", |
| 765 | +return_value=locale): |
| 766 | +self.assertEqual(gettext._expand_lang(locale),expanded) |
| 767 | + |
| 768 | + |
742 | 769 | classMiscTestCase(unittest.TestCase):
|
743 | 770 | deftest__all__(self):
|
744 | 771 | support.check__all__(self,gettext,
|
|