(self)
| 635 | |
| 636 | class TestMiscellaneous(unittest.TestCase): |
| 637 | def test_defaults_UTF8(self): |
| 638 | # Issue #18378: on (at least) macOS setting LC_CTYPE to "UTF-8" is |
| 639 | # valid. Furthermore LC_CTYPE=UTF is used by the UTF-8 locale coercing |
| 640 | # during interpreter startup (on macOS). |
| 641 | import _locale |
| 642 | |
| 643 | self.assertEqual(locale._parse_localename('UTF-8'), (None, 'UTF-8')) |
| 644 | |
| 645 | if hasattr(_locale, '_getdefaultlocale'): |
| 646 | orig_getlocale = _locale._getdefaultlocale |
| 647 | del _locale._getdefaultlocale |
| 648 | else: |
| 649 | orig_getlocale = None |
| 650 | |
| 651 | try: |
| 652 | with os_helper.EnvironmentVarGuard() as env: |
| 653 | env.unset('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE') |
| 654 | env.set('LC_CTYPE', 'UTF-8') |
| 655 | |
| 656 | self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8')) |
| 657 | finally: |
| 658 | if orig_getlocale is not None: |
| 659 | _locale._getdefaultlocale = orig_getlocale |
| 660 | |
| 661 | def test_getencoding(self): |
| 662 | # Invoke getencoding to make sure it does not cause exceptions. |
nothing calls this directly
no test coverage detected