diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2015-04-13 18:01:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2015-04-13 18:01:21 (GMT) |
commit | 85e3ee749c351ebe0ad1ec28856d64da50b13f20 (patch) | |
tree | 55dc2ddb8c1085bf4271a35e72d0697035426c4a /Lib/test/test_io.py | |
parent | 20d31b5182bebdf433c1b1c124377895333adbec (diff) | |
download | cpython-85e3ee749c351ebe0ad1ec28856d64da50b13f20.zip cpython-85e3ee749c351ebe0ad1ec28856d64da50b13f20.tar.gz cpython-85e3ee749c351ebe0ad1ec28856d64da50b13f20.tar.bz2 |
Issue #22982: Improve BOM handling when seeking to multiple positions of a writable text file.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index dfa3d77..ea109ac 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2669,6 +2669,19 @@ class TextIOWrapperTest(unittest.TestCase): with self.open(filename, 'rb') as f: self.assertEqual(f.read(), 'bbbzzz'.encode(charset)) + def test_seek_append_bom(self): + # Same test, but first seek to the start and then to the end + filename = support.TESTFN + for charset in ('utf-8-sig', 'utf-16', 'utf-32'): + with self.open(filename, 'w', encoding=charset) as f: + f.write('aaa') + with self.open(filename, 'a', encoding=charset) as f: + f.seek(0) + f.seek(0, self.SEEK_END) + f.write('xxx') + with self.open(filename, 'rb') as f: + self.assertEqual(f.read(), 'aaaxxx'.encode(charset)) + def test_errors_property(self): with self.open(support.TESTFN, "w") as f: self.assertEqual(f.errors, "strict") |