diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-02-26 10:40:58 +0000 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-02-26 10:40:58 +0000 |
commit | f4b6186d9c3677f96183d4c9e7267c0b960c9132 (patch) | |
tree | ef30da79386105985047553daf257cfee5dedda8 /Lib/test/test_codecs.py | |
parent | c994186dad39eee832112318d63f96189d8f2b57 (diff) | |
download | cpython-git-f4b6186d9c3677f96183d4c9e7267c0b960c9132.tar.gz |
#691291: codecs.open() should not convert end of lines on reading and writing.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 175f92b9ea..8caf018259 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -437,6 +437,21 @@ class UTF16Test(ReadTest): def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True) + def test_bug691291(self): + # Files are always opened in binary mode, even if no binary mode was + # specified. This means that no automatic conversion of '\n' is done + # on reading and writing. + s1 = u'Hello\r\nworld\r\n' + + s = s1.encode(self.encoding) + try: + with open(test_support.TESTFN, 'wb') as fp: + fp.write(s) + with codecs.open(test_support.TESTFN, 'U', encoding=self.encoding) as reader: + self.assertEqual(reader.read(), s1) + finally: + test_support.unlink(test_support.TESTFN) + class UTF16LETest(ReadTest): encoding = "utf-16-le" |