diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22723bdc6..d4c9771ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,11 +92,6 @@ jobs: python-version: "pypy-3.10" - os: "windows-latest" python-version: "pypy-3.10" - # TODO: 3.12 setlocale(...) is broken on Windows & Mac - - os: "macos-latest" - python-version: "3.12" - - os: "windows-latest" - python-version: "3.12" steps: - uses: actions/checkout@v3 with: diff --git a/changelog.d/+py312-setlocale-fail.infrastructure.md b/changelog.d/+py312-setlocale-fail.infrastructure.md new file mode 100644 index 000000000..d13015278 --- /dev/null +++ b/changelog.d/+py312-setlocale-fail.infrastructure.md @@ -0,0 +1 @@ +Fixed tests failing because of changes made to `locale.normalize` in Python 3.12. diff --git a/test/unit/b2http/test_b2http.py b/test/unit/b2http/test_b2http.py index 4ab4da27b..d77c034a2 100644 --- a/test/unit/b2http/test_b2http.py +++ b/test/unit/b2http/test_b2http.py @@ -11,6 +11,7 @@ import datetime import locale +import sys from unittest.mock import MagicMock, call, patch import apiver_deps @@ -306,9 +307,11 @@ class TestB2HttpUserAgentAppend(TestB2Http): class TestSetLocaleContextManager(TestBase): def test_set_locale_context_manager(self): - test_locale = locale.normalize( - 'C.utf8' - ) # C.UTF-8 on Ubuntu 18.04 Bionic, C.utf8 on Ubuntu 22.04 Jammy + # C.UTF-8 on Ubuntu 18.04 Bionic, C.utf8 on Ubuntu 22.04 Jammy + # Neither macOS nor Windows have C.UTF-8 locale, and they use `en_US.UTF-8`. + # Since Python 3.12, locale.normalize no longer falls back + # to the `en_US` version, so we're providing it here manually. + test_locale = locale.normalize('C.UTF-8' if sys.platform == 'linux' else 'en_US.UTF-8') other_locale = 'C' saved = locale.setlocale(locale.LC_ALL)