(self)
| 536 | |
| 537 | class TestMiscellaneous(unittest.TestCase): |
| 538 | def test_defaults_UTF8(self): |
| 539 | # Issue #18378: on (at least) macOS setting LC_CTYPE to "UTF-8" is |
| 540 | # valid. Furthermore LC_CTYPE=UTF is used by the UTF-8 locale coercing |
| 541 | # during interpreter startup (on macOS). |
| 542 | import _locale |
| 543 | |
| 544 | self.assertEqual(locale._parse_localename('UTF-8'), (None, 'UTF-8')) |
| 545 | |
| 546 | if hasattr(_locale, '_getdefaultlocale'): |
| 547 | orig_getlocale = _locale._getdefaultlocale |
| 548 | del _locale._getdefaultlocale |
| 549 | else: |
| 550 | orig_getlocale = None |
| 551 | |
| 552 | try: |
| 553 | with os_helper.EnvironmentVarGuard() as env: |
| 554 | env.unset('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE') |
| 555 | env.set('LC_CTYPE', 'UTF-8') |
| 556 | |
| 557 | with check_warnings(('', DeprecationWarning)): |
| 558 | self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8')) |
| 559 | finally: |
| 560 | if orig_getlocale is not None: |
| 561 | _locale._getdefaultlocale = orig_getlocale |
| 562 | |
| 563 | def test_getencoding(self): |
| 564 | # Invoke getencoding to make sure it does not cause exceptions. |
nothing calls this directly
no test coverage detected