(self)
| 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() |
nothing calls this directly
no test coverage detected