diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-03-31 11:52:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 11:52:31 (GMT) |
commit | e143eea4b56ac7ae611e5bcc41eedbc572aa41c3 (patch) | |
tree | ebf29351fa5350a7b6c3e58a201ab6321780273b | |
parent | e92923b028024290a0e621b6b90e3221767d14d4 (diff) | |
download | cpython-e143eea4b56ac7ae611e5bcc41eedbc572aa41c3.zip cpython-e143eea4b56ac7ae611e5bcc41eedbc572aa41c3.tar.gz cpython-e143eea4b56ac7ae611e5bcc41eedbc572aa41c3.tar.bz2 |
bpo-37945: Fix test_locale.test_getsetlocale_issue1813() (GH-25110) (GH-25113)
Skip the test if setlocale() fails.
(cherry picked from commit f3ab670fea75ebe177e3412a5ebe39263cd428e3)
Co-authored-by: Victor Stinner <vstinner@python.org>
-rw-r--r-- | Lib/test/test_locale.py | 8 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2021-03-31-11-38-42.bpo-37945.HTUYhv.rst | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index c5d8e26..39091c0 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -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 index 0000000..e1c95f6 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2021-03-31-11-38-42.bpo-37945.HTUYhv.rst @@ -0,0 +1,2 @@ +Fix test_getsetlocale_issue1813() of test_locale: skip the test if +``setlocale()`` fails. Patch by Victor Stinner. |