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

Method test_bug691291

Lib/test/test_codecs.py:714–727  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

712 "spamspam", self.spambe)
713
714 def test_bug691291(self):
715 # If encoding is not None, then
716 # files are always opened in binary mode, even if no binary mode was
717 # specified. This means that no automatic conversion of '\n' is done
718 # on reading and writing.
719 s1 = 'Hello\r\nworld\r\n'
720
721 s = s1.encode(self.encoding)
722 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
723 with open(os_helper.TESTFN, 'wb') as fp:
724 fp.write(s)
725 with codecs_open_no_warn(os_helper.TESTFN, 'r',
726 encoding=self.encoding) as reader:
727 self.assertEqual(reader.read(), s1)
728
729 def test_invalid_modes(self):
730 for mode in ('U', 'rU', 'r+U'):

Callers

nothing calls this directly

Calls 7

codecs_open_no_warnFunction · 0.85
addCleanupMethod · 0.80
openFunction · 0.50
encodeMethod · 0.45
writeMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected