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

Method test_open_default_encoding

Lib/test/test_builtin.py:1718–1731  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1716
1717 @unittest.skipIf(sys.flags.utf8_mode, "utf-8 mode is enabled")
1718 def test_open_default_encoding(self):
1719 with EnvironmentVarGuard() as env:
1720 # try to get a user preferred encoding different than the current
1721 # locale encoding to check that open() uses the current locale
1722 # encoding and not the user preferred encoding
1723 env.unset('LC_ALL', 'LANG', 'LC_CTYPE')
1724
1725 self.write_testfile()
1726 current_locale_encoding = locale.getencoding()
1727 with warnings.catch_warnings():
1728 warnings.simplefilter("ignore", EncodingWarning)
1729 fp = open(TESTFN, 'w')
1730 with fp:
1731 self.assertEqual(fp.encoding, current_locale_encoding)
1732
1733 @support.requires_subprocess()
1734 def test_open_non_inheritable(self):

Callers

nothing calls this directly

Calls 5

write_testfileMethod · 0.95
EnvironmentVarGuardClass · 0.90
unsetMethod · 0.80
openFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected