MCPcopy Index your code
hub / github.com/python/cpython / test_defaults_UTF8

Method test_defaults_UTF8

Lib/test/test_locale.py:637–659  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

635
636class 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.

Callers

nothing calls this directly

Calls 3

unsetMethod · 0.80
assertEqualMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected