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

Method test_reconfigure_write

Lib/test/test_io.py:3885–3904  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3883 self.assertEqual(raw.getvalue(), b'foo\n\xc3\xa9\n')
3884
3885 def test_reconfigure_write(self):
3886 # latin -> utf8
3887 raw = self.BytesIO()
3888 txt = self.TextIOWrapper(raw, encoding='latin1', newline='\n')
3889 txt.write('abc\xe9\n')
3890 txt.reconfigure(encoding='utf-8')
3891 self.assertEqual(raw.getvalue(), b'abc\xe9\n')
3892 txt.write('d\xe9f\n')
3893 txt.flush()
3894 self.assertEqual(raw.getvalue(), b'abc\xe9\nd\xc3\xa9f\n')
3895
3896 # ascii -> utf-8-sig: ensure that no BOM is written in the middle of
3897 # the file
3898 raw = self.BytesIO()
3899 txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n')
3900 txt.write('abc\n')
3901 txt.reconfigure(encoding='utf-8-sig')
3902 txt.write('d\xe9f\n')
3903 txt.flush()
3904 self.assertEqual(raw.getvalue(), b'abc\nd\xc3\xa9f\n')
3905
3906 def test_reconfigure_write_non_seekable(self):
3907 raw = self.BytesIO()

Callers

nothing calls this directly

Calls 5

writeMethod · 0.95
reconfigureMethod · 0.95
getvalueMethod · 0.95
flushMethod · 0.95
assertEqualMethod · 0.45

Tested by

no test coverage detected