mirror of
https://github.com/python/cpython.git
synced 2025-10-28 04:04:44 +00:00
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.
This commit is contained in:
parent
af504ca017
commit
2d556f56db
1 changed files with 10 additions and 1 deletions
|
|
@ -127,6 +127,7 @@
|
|||
import faulthandler
|
||||
import io
|
||||
import json
|
||||
import locale
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
|
|
@ -1061,7 +1062,7 @@ def __init__(self, testname, verbose=0, quiet=False):
|
|||
'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 @@ def restore_support_TESTFN(self, saved_value):
|
|||
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('.', '_')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue