see if we can get this to work on windows

This commit is contained in:
Benjamin Peterson 2009-05-04 21:28:12 +00:00
parent 3c33e087fc
commit ec75312eaa
1 changed files with 16 additions and 8 deletions

View File

@ -1,6 +1,7 @@
from test.support import verbose, run_unittest from test.support import verbose, run_unittest
from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo, import _locale
localeconv, Error) from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, nl_langinfo,
localeconv, Error)
import unittest import unittest
from platform import uname from platform import uname
@ -25,6 +26,10 @@ candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT',
# value is not known, use '' . # value is not known, use '' .
known_numerics = {'fr_FR' : (',', ''), 'en_US':('.', ',')} known_numerics = {'fr_FR' : (',', ''), 'en_US':('.', ',')}
def needs_radix_and_thousands(func):
return unittest.skipUnless(hasattr(_locale, "RADIXCHAR"),
"needs RADIXCHAR and THOUSEP")(func)
class _LocaleTests(unittest.TestCase): class _LocaleTests(unittest.TestCase):
def setUp(self): def setUp(self):
@ -53,6 +58,7 @@ class _LocaleTests(unittest.TestCase):
calc_type, data_type, set_locale, calc_type, data_type, set_locale,
used_locale)) used_locale))
@needs_radix_and_thousands
def test_lc_numeric_nl_langinfo(self): def test_lc_numeric_nl_langinfo(self):
# Test nl_langinfo against known values # Test nl_langinfo against known values
for loc in candidate_locales: for loc in candidate_locales:
@ -61,10 +67,11 @@ class _LocaleTests(unittest.TestCase):
setlocale(LC_CTYPE, loc) setlocale(LC_CTYPE, loc)
except Error: except Error:
continue continue
for li, lc in ((RADIXCHAR, "decimal_point"), for li, lc in ((_locale.RADIXCHAR, "decimal_point"),
(THOUSEP, "thousands_sep")): (_locale.THOUSEP, "thousands_sep")):
self.numeric_tester('nl_langinfo', nl_langinfo(li), lc, loc) self.numeric_tester('nl_langinfo', nl_langinfo(li), lc, loc)
@needs_radix_and_thousands
def test_lc_numeric_localeconv(self): def test_lc_numeric_localeconv(self):
# Test localeconv against known values # Test localeconv against known values
for loc in candidate_locales: for loc in candidate_locales:
@ -73,10 +80,11 @@ class _LocaleTests(unittest.TestCase):
setlocale(LC_CTYPE, loc) setlocale(LC_CTYPE, loc)
except Error: except Error:
continue continue
for li, lc in ((RADIXCHAR, "decimal_point"), for li, lc in ((_locale.RADIXCHAR, "decimal_point"),
(THOUSEP, "thousands_sep")): (_locale.THOUSEP, "thousands_sep")):
self.numeric_tester('localeconv', localeconv()[lc], lc, loc) self.numeric_tester('localeconv', localeconv()[lc], lc, loc)
@needs_radix_and_thousands
def test_lc_numeric_basic(self): def test_lc_numeric_basic(self):
# Test nl_langinfo against localeconv # Test nl_langinfo against localeconv
for loc in candidate_locales: for loc in candidate_locales:
@ -85,8 +93,8 @@ class _LocaleTests(unittest.TestCase):
setlocale(LC_CTYPE, loc) setlocale(LC_CTYPE, loc)
except Error: except Error:
continue continue
for li, lc in ((RADIXCHAR, "decimal_point"), for li, lc in ((_locale.RADIXCHAR, "decimal_point"),
(THOUSEP, "thousands_sep")): (_locale.THOUSEP, "thousands_sep")):
nl_radixchar = nl_langinfo(li) nl_radixchar = nl_langinfo(li)
li_radixchar = localeconv()[lc] li_radixchar = localeconv()[lc]
try: try: