16
16
17
17
import pandas .util .testing as tm
18
18
19
- CURRENT_LOCALE = locale .getlocale ()
20
- LOCALE_OVERRIDE = os .environ .get ('LOCALE_OVERRIDE' , None )
21
-
22
19
23
20
class TestDecorators (object ):
24
21
@@ -412,6 +409,7 @@ class TestLocaleUtils(object):
412
409
@classmethod
413
410
def setup_class (cls ):
414
411
cls .locales = tm .get_locales ()
412
+ cls .current_locale = locale .getlocale ()
415
413
416
414
if not cls .locales :
417
415
pytest .skip ("No locales found" )
@@ -421,6 +419,7 @@ def setup_class(cls):
421
419
@classmethod
422
420
def teardown_class (cls ):
423
421
del cls .locales
422
+ del cls .current_locale
424
423
425
424
def test_get_locales (self ):
426
425
# all systems should have at least a single locale
@@ -438,17 +437,19 @@ def test_set_locale(self):
438
437
pytest .skip ("Only a single locale found, no point in "
439
438
"trying to test setting another locale" )
440
439
441
- if all (x is None for x in CURRENT_LOCALE ):
440
+ if all (x is None for x in self . current_locale ):
442
441
# Not sure why, but on some travis runs with pytest,
443
442
# 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 )
445
446
446
- if LOCALE_OVERRIDE is None :
447
+ if locale_override is None :
447
448
lang , enc = 'it_CH' , 'UTF-8'
448
- elif LOCALE_OVERRIDE == 'C' :
449
+ elif locale_override == 'C' :
449
450
lang , enc = 'en_US' , 'ascii'
450
451
else :
451
- lang , enc = LOCALE_OVERRIDE .split ('.' )
452
+ lang , enc = locale_override .split ('.' )
452
453
453
454
enc = codecs .lookup (enc ).name
454
455
new_locale = lang , enc
@@ -465,4 +466,4 @@ def test_set_locale(self):
465
466
assert normalized_locale == new_locale
466
467
467
468
current_locale = locale .getlocale ()
468
- assert current_locale == CURRENT_LOCALE
469
+ assert current_locale == self . current_locale
0 commit comments