1616
1717import pandas .util .testing as tm
1818
19- CURRENT_LOCALE = locale .getlocale ()
20- LOCALE_OVERRIDE = os .environ .get ('LOCALE_OVERRIDE' , None )
21-
2219
2320class TestDecorators (object ):
2421
@@ -412,6 +409,7 @@ class TestLocaleUtils(object):
412409 @classmethod
413410 def setup_class (cls ):
414411 cls .locales = tm .get_locales ()
412+ cls .current_locale = locale .getlocale ()
415413
416414 if not cls .locales :
417415 pytest .skip ("No locales found" )
@@ -421,6 +419,7 @@ def setup_class(cls):
421419 @classmethod
422420 def teardown_class (cls ):
423421 del cls .locales
422+ del cls .current_locale
424423
425424 def test_get_locales (self ):
426425 # all systems should have at least a single locale
@@ -438,17 +437,19 @@ def test_set_locale(self):
438437 pytest .skip ("Only a single locale found, no point in "
439438 "trying to test setting another locale" )
440439
441- if all (x is None for x in CURRENT_LOCALE ):
440+ if all (x is None for x in self . current_locale ):
442441 # Not sure why, but on some travis runs with pytest,
443442 # getlocale() returned (None, None).
444- pytest .skip ("CURRENT_LOCALE is not set." )
443+ pytest .skip ("Current locale is not set." )
444+
445+ locale_override = os .environ .get ('LOCALE_OVERRIDE' , None )
445446
446- if LOCALE_OVERRIDE is None :
447+ if locale_override is None :
447448 lang , enc = 'it_CH' , 'UTF-8'
448- elif LOCALE_OVERRIDE == 'C' :
449+ elif locale_override == 'C' :
449450 lang , enc = 'en_US' , 'ascii'
450451 else :
451- lang , enc = LOCALE_OVERRIDE .split ('.' )
452+ lang , enc = locale_override .split ('.' )
452453
453454 enc = codecs .lookup (enc ).name
454455 new_locale = lang , enc
@@ -465,4 +466,4 @@ def test_set_locale(self):
465466 assert normalized_locale == new_locale
466467
467468 current_locale = locale .getlocale ()
468- assert current_locale == CURRENT_LOCALE
469+ assert current_locale == self . current_locale
0 commit comments