MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_defaults_UTF8

Method test_defaults_UTF8

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

Source from the content-addressed store, hash-verified

536
537class 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.

Callers

nothing calls this directly

Calls 5

check_warningsFunction · 0.90
hasattrFunction · 0.85
unsetMethod · 0.80
assertEqualMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected