summaryrefslogtreecommitdiff
path: root/Lib/test/regrtest.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-04-01 12:53:13 -0400
committerBrett Cannon <brett@python.org>2013-04-01 12:53:13 -0400
commit2d556f56db942364ceca2bc19630db56f75e302f (patch)
treef478b12fc6663416441320f221b2dcc099b4d60e /Lib/test/regrtest.py
parentaf504ca017af63e5dc85f7053bf40c95a428785a (diff)
downloadcpython-git-2d556f56db942364ceca2bc19630db56f75e302f.tar.gz
Issue #14135: Make sure tests don't leave the locale changed for any
category. Thanks to Westley Martinez for trying to fix the issue and Atsuo Ishimoto for an initial patch.
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-xLib/test/regrtest.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 45b454116f..4f74780276 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -127,6 +127,7 @@ import builtins
import faulthandler
import io
import json
+import locale
import logging
import os
import platform
@@ -1061,7 +1062,7 @@ class saved_test_environment:
'sys.warnoptions', 'threading._dangling',
'multiprocessing.process._dangling',
'sysconfig._CONFIG_VARS', 'sysconfig._INSTALL_SCHEMES',
- 'support.TESTFN',
+ 'support.TESTFN', 'locale'
)
def get_sys_argv(self):
@@ -1230,6 +1231,14 @@ class saved_test_environment:
elif os.path.isdir(support.TESTFN):
shutil.rmtree(support.TESTFN)
+ _locale_categories = [getattr(locale, lc)
+ for lc in dir(locale) if lc.startswith('LC_')]
+ def get_locale(self):
+ return tuple(map(locale.getlocale, self._locale_categories))
+ def restore_locale(self, saved):
+ for category, setting in zip(self._locale_categories, saved):
+ locale.setlocale(category, setting)
+
def resource_info(self):
for name in self.resources:
method_suffix = name.replace('.', '_')