Skip to content

Commit e143eea

Browse files
bpo-37945: Fix test_locale.test_getsetlocale_issue1813() (GH-25110) (GH-25113)
Skip the test if setlocale() fails. (cherry picked from commit f3ab670) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent e92923b commit e143eea

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Lib/test/test_locale.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,13 @@ def test_getsetlocale_issue1813(self):
564564
loc = locale.getlocale(locale.LC_CTYPE)
565565
if verbose:
566566
print('testing with %a' % (loc,), end=' ', flush=True)
567-
locale.setlocale(locale.LC_CTYPE, loc)
567+
try:
568+
locale.setlocale(locale.LC_CTYPE, loc)
569+
except locale.Error as exc:
570+
# bpo-37945: setlocale(LC_CTYPE) fails with getlocale(LC_CTYPE)
571+
# and the tr_TR locale on Windows. getlocale() builds a locale
572+
# which is not recognize by setlocale().
573+
self.skipTest(f"setlocale(LC_CTYPE, {loc!r}) failed: {exc!r}")
568574
self.assertEqual(loc, locale.getlocale(locale.LC_CTYPE))
569575

570576
def test_invalid_locale_format_in_localetuple(self):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix test_getsetlocale_issue1813() of test_locale: skip the test if
2+
``setlocale()`` fails. Patch by Victor Stinner.

0 commit comments

Comments
 (0)