0001 from test.test_support import verbose, TestSkipped, run_unittest 0002 from _locale import (setlocale, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo, 0003 localeconv, Error) 0004 import unittest 0005 0006 candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT', 0007 'et_EE', 'es_PY', 'no_NO', 'nl_NL', 'lv_LV', 'el_GR', 'be_BY', 'fr_BE', 0008 'ro_RO', 'ru_UA', 'ru_RU', 'es_VE', 'ca_ES', 'se_NO', 'es_EC', 'id_ID', 0009 'ka_GE', 'es_CL', 'hu_HU', 'wa_BE', 'lt_LT', 'sl_SI', 'hr_HR', 'es_AR', 0010 'es_ES', 'oc_FR', 'gl_ES', 'bg_BG', 'is_IS', 'mk_MK', 'de_AT', 'pt_BR', 0011 'da_DK', 'nn_NO', 'cs_CZ', 'de_LU', 'es_BO', 'sq_AL', 'sk_SK', 'fr_CH', 0012 'de_DE', 'sr_YU', 'br_FR', 'nl_BE', 'sv_FI', 'pl_PL', 'fr_CA', 'fo_FO', 0013 'bs_BA', 'fr_LU', 'kl_GL', 'fa_IR', 'de_BE', 'sv_SE', 'it_CH', 'uk_UA', 0014 'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ', 0015 'es_ES.ISO8859-1', 'fr_FR.ISO8859-15', 'ru_RU.KOI8-R', 'ko_KR.eucKR'] 0016 0017 class _LocaleTests(unittest.TestCase): 0018 0019 def setUp(self): 0020 self.oldlocale = setlocale(LC_NUMERIC) 0021 0022 def tearDown(self): 0023 setlocale(LC_NUMERIC, self.oldlocale) 0024 0025 def test_lc_numeric(self): 0026 for loc in candidate_locales: 0027 try: 0028 setlocale(LC_NUMERIC, loc) 0029 except Error: 0030 continue 0031 for li, lc in ((RADIXCHAR, "decimal_point"), 0032 (THOUSEP, "thousands_sep")): 0033 nl_radixchar = nl_langinfo(li) 0034 li_radixchar = localeconv()[lc] 0035 # Both with seeing what the locale is set to in order to detect 0036 # when setlocale lies and says it accepted the locale setting 0037 # but in actuality didn't use it (as seen in OS X 10.3) 0038 try: 0039 set_locale = setlocale(LC_NUMERIC) 0040 except Error: 0041 set_locale = "<not able to determine>" 0042 self.assertEquals(nl_radixchar, li_radixchar, 0043 "%s != %s (%s); " 0044 "supposed to be %s, set to %s" % 0045 (nl_radixchar, li_radixchar, lc, 0046 loc, set_locale)) 0047 0048 def test_main(): 0049 run_unittest(_LocaleTests) 0050 0051 if __name__ == '__main__': 0052 test_main() 0053
Generated by PyXR 0.9.4