]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-37945: Fix test_locale.test_getsetlocale_issue1813() (GH-25110) (GH-25113)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 31 Mar 2021 11:52:31 +0000 (04:52 -0700)
committerGitHub <noreply@github.com>
Wed, 31 Mar 2021 11:52:31 +0000 (13:52 +0200)
Skip the test if setlocale() fails.
(cherry picked from commit f3ab670fea75ebe177e3412a5ebe39263cd428e3)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_locale.py
Misc/NEWS.d/next/Tests/2021-03-31-11-38-42.bpo-37945.HTUYhv.rst [new file with mode: 0644]

index c5d8e269d631834d67e54189269ee2d1c2e7af2e..39091c04f494a30e1ced12dfdcb702bd54db8aa9 100644 (file)
@@ -564,7 +564,13 @@ class TestMiscellaneous(unittest.TestCase):
         loc = locale.getlocale(locale.LC_CTYPE)
         if verbose:
             print('testing with %a' % (loc,), end=' ', flush=True)
-        locale.setlocale(locale.LC_CTYPE, loc)
+        try:
+            locale.setlocale(locale.LC_CTYPE, loc)
+        except locale.Error as exc:
+            # bpo-37945: setlocale(LC_CTYPE) fails with getlocale(LC_CTYPE)
+            # and the tr_TR locale on Windows. getlocale() builds a locale
+            # which is not recognize by setlocale().
+            self.skipTest(f"setlocale(LC_CTYPE, {loc!r}) failed: {exc!r}")
         self.assertEqual(loc, locale.getlocale(locale.LC_CTYPE))
 
     def test_invalid_locale_format_in_localetuple(self):
diff --git a/Misc/NEWS.d/next/Tests/2021-03-31-11-38-42.bpo-37945.HTUYhv.rst b/Misc/NEWS.d/next/Tests/2021-03-31-11-38-42.bpo-37945.HTUYhv.rst
new file mode 100644 (file)
index 0000000..e1c95f6
--- /dev/null
@@ -0,0 +1,2 @@
+Fix test_getsetlocale_issue1813() of test_locale: skip the test if
+``setlocale()`` fails. Patch by Victor Stinner.