summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-11-29 15:33:18 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-11-29 15:33:18 (GMT)
commit3c8ef8f1003497711e0a3fa0002046c8e57d1e36 (patch)
tree83ebf7e65843a9df16cd086ba3c964d4dd0ddd60
parentd26b66313eb0197aadb7a463ae3bc8b76f504a74 (diff)
downloadcpython-3c8ef8f1003497711e0a3fa0002046c8e57d1e36.zip
cpython-3c8ef8f1003497711e0a3fa0002046c8e57d1e36.tar.gz
cpython-3c8ef8f1003497711e0a3fa0002046c8e57d1e36.tar.bz2
Issue #25742: Try to fix test_locale on Windows
-rw-r--r--Lib/test/test_locale.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py
index 140388a..563ddb1 100644
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -494,14 +494,14 @@ class TestMiscellaneous(unittest.TestCase):
self.assertEqual(locale.normalize(u'en_US'), 'en_US.ISO8859-1')
def test_setlocale_unicode(self):
- old_loc = locale.getlocale(locale.LC_ALL)
- try:
- user_locale = locale.setlocale(locale.LC_ALL, '')
- unicode_locale = user_locale.decode('utf-8')
- user_locale2 = locale.setlocale(locale.LC_ALL, unicode_locale)
- self.assertEqual(user_locale, user_locale2)
- finally:
- locale.setlocale(locale.LC_ALL, old_loc)
+ oldlocale = locale.getlocale()
+ self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
+
+ user_locale = locale.setlocale(locale.LC_CTYPE, '')
+ unicode_locale = user_locale.decode('utf-8')
+
+ user_locale2 = locale.setlocale(locale.LC_CTYPE, unicode_locale)
+ self.assertEqual(user_locale, user_locale2)
def test_main():