Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95366:2d33f43487c5
Date: 2018-11-25 12:30 -0600
http://bitbucket.org/pypy/pypy/changeset/2d33f43487c5/
Log: improve and add a test
diff --git a/pypy/module/_locale/test/test_locale.py
b/pypy/module/_locale/test/test_locale.py
--- a/pypy/module/_locale/test/test_locale.py
+++ b/pypy/module/_locale/test/test_locale.py
@@ -20,6 +20,7 @@
# check whether used locales are installed, otherwise the tests will
# fail
current = _locale.setlocale(_locale.LC_ALL)
+ cls.oldlocale = current
try:
try:
# some systems are only UTF-8 oriented
@@ -45,6 +46,12 @@
finally:
_locale.setlocale(_locale.LC_ALL, current)
+ def teardown_class(cls):
+ import _locale
+ _locale.setlocale(_locale.LC_ALL, cls.oldlocale)
+
+
+
def test_import(self):
import _locale
assert _locale
@@ -299,3 +306,36 @@
assert lang is None or isinstance(lang, str)
assert encoding.startswith('cp')
+ def test_lc_numeric_basic(self):
+ from _locale import (setlocale, nl_langinfo, Error, LC_NUMERIC,
+ LC_CTYPE, RADIXCHAR, THOUSEP, localeconv)
+ # Test nl_langinfo against localeconv
+ candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT',
'it_IT',
+ 'et_EE', 'es_PY', 'no_NO', 'nl_NL', 'lv_LV', 'el_GR', 'be_BY',
'fr_BE',
+ 'ro_RO', 'ru_UA', 'ru_RU', 'es_VE', 'ca_ES', 'se_NO', 'es_EC',
'id_ID',
+ 'ka_GE', 'es_CL', 'wa_BE', 'hu_HU', 'lt_LT', 'sl_SI', 'hr_HR',
'es_AR',
+ 'es_ES', 'oc_FR', 'gl_ES', 'bg_BG', 'is_IS', 'mk_MK', 'de_AT',
'pt_BR',
+ 'da_DK', 'nn_NO', 'cs_CZ', 'de_LU', 'es_BO', 'sq_AL', 'sk_SK',
'fr_CH',
+ 'de_DE', 'sr_YU', 'br_FR', 'nl_BE', 'sv_FI', 'pl_PL', 'fr_CA',
'fo_FO',
+ 'bs_BA', 'fr_LU', 'kl_GL', 'fa_IR', 'de_BE', 'sv_SE', 'it_CH',
'uk_UA',
+ 'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ', 'ps_AF',
'en_US',
+ 'fr_FR.ISO8859-1', 'fr_FR.UTF-8', 'fr_FR.ISO8859-15@euro',
+ 'ru_RU.KOI8-R', 'ko_KR.eucKR']
+
+ tested = False
+ for loc in candidate_locales:
+ try:
+ setlocale(LC_NUMERIC, loc)
+ setlocale(LC_CTYPE, loc)
+ except Error:
+ continue
+ for li, lc in ((RADIXCHAR, "decimal_point"),
+ (THOUSEP, "thousands_sep")):
+ nl_radixchar = nl_langinfo(li)
+ li_radixchar = localeconv()[lc]
+ try:
+ set_locale = setlocale(LC_NUMERIC)
+ except Error:
+ set_locale = "<not able to determine>"
+ assert nl_radixchar == li_radixchar, ("nl_langinfo !=
localeconv "
+ "(set to %s, using %s)" % ( loc, set_locale))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit