From c8a06aa54139120e3ecaae462b2d02cb8e92041c Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Thu, 13 May 2010 12:47:23 +0000 Subject: ENH: core/test: try more locales out in_foreign_locale to make it work also on modern Linux systems --- numpy/core/tests/test_print.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'numpy') diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py index 3407528db..d83f21cb2 100644 --- a/numpy/core/tests/test_print.py +++ b/numpy/core/tests/test_print.py @@ -200,19 +200,26 @@ def test_complex_type_print(): # Locale tests: scalar types formatting should be independent of the locale def in_foreign_locale(func): - # XXX: How to query locale on a given system ? + """ + Swap LC_NUMERIC locale to one in which the decimal point is ',' and not '.' + If not possible, raise nose.SkipTest + + """ + if sys.platform == 'win32': + locales = ['FRENCH'] + else: + locales = ['fr_FR', 'fr_FR.UTF-8', 'fi_FI', 'fi_FI.UTF-8'] - # French is one language where the decimal is ',' not '.', and should be - # relatively common on many systems def wrapper(*args, **kwargs): curloc = locale.getlocale(locale.LC_NUMERIC) try: - try: - if not sys.platform == 'win32': - locale.setlocale(locale.LC_NUMERIC, 'fr_FR') - else: - locale.setlocale(locale.LC_NUMERIC, 'FRENCH') - except locale.Error: + for loc in locales: + try: + locale.setlocale(locale.LC_NUMERIC, loc) + break + except locale.Error: + pass + else: raise nose.SkipTest("Skipping locale test, because " "French locale not found") return func(*args, **kwargs) -- cgit v1.2.1