Skip to content

Commit

Permalink
TST: Patch locale failure on Circle
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung committed May 12, 2017
1 parent ade6398 commit c278362
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pandas/tests/util/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

import pandas.util.testing as tm

CURRENT_LOCALE = locale.getlocale()
LOCALE_OVERRIDE = os.environ.get('LOCALE_OVERRIDE', None)


class TestDecorators(object):

Expand Down Expand Up @@ -412,6 +409,7 @@ class TestLocaleUtils(object):
@classmethod
def setup_class(cls):
cls.locales = tm.get_locales()
cls.current_locale = locale.getlocale()

if not cls.locales:
pytest.skip("No locales found")
Expand All @@ -421,6 +419,7 @@ def setup_class(cls):
@classmethod
def teardown_class(cls):
del cls.locales
del cls.current_locale

def test_get_locales(self):
# all systems should have at least a single locale
Expand All @@ -438,17 +437,19 @@ def test_set_locale(self):
pytest.skip("Only a single locale found, no point in "
"trying to test setting another locale")

if all(x is None for x in CURRENT_LOCALE):
if all(x is None for x in self.current_locale):
# Not sure why, but on some travis runs with pytest,
# getlocale() returned (None, None).
pytest.skip("CURRENT_LOCALE is not set.")
pytest.skip("Current locale is not set.")

locale_override = os.environ.get('LOCALE_OVERRIDE', None)

if LOCALE_OVERRIDE is None:
if locale_override is None:
lang, enc = 'it_CH', 'UTF-8'
elif LOCALE_OVERRIDE == 'C':
elif locale_override == 'C':
lang, enc = 'en_US', 'ascii'
else:
lang, enc = LOCALE_OVERRIDE.split('.')
lang, enc = locale_override.split('.')

enc = codecs.lookup(enc).name
new_locale = lang, enc
Expand All @@ -465,4 +466,4 @@ def test_set_locale(self):
assert normalized_locale == new_locale

current_locale = locale.getlocale()
assert current_locale == CURRENT_LOCALE
assert current_locale == self.current_locale

0 comments on commit c278362

Please sign in to comment.