summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-02-27 11:26:58 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-02-27 11:26:58 (GMT)
commitc92fc8261dd89cfc1d11a5aee28ed28df4579346 (patch)
treef4e95bb7adaef961db7a04a54f15280fd7ae41a4 /Lib/test/test_codecs.py
parent9ea3bbafaa7a7e8e1b98dcf993b4aadad85bdf5a (diff)
downloadcpython-c92fc8261dd89cfc1d11a5aee28ed28df4579346.zip
cpython-c92fc8261dd89cfc1d11a5aee28ed28df4579346.tar.gz
cpython-c92fc8261dd89cfc1d11a5aee28ed28df4579346.tar.bz2
Merged revisions 78461,78482 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78461 | florent.xicluna | 2010-02-26 11:40:58 +0100 (ven, 26 fév 2010) | 2 lines #691291: codecs.open() should not convert end of lines on reading and writing. ........ r78482 | florent.xicluna | 2010-02-27 12:19:18 +0100 (sam, 27 fév 2010) | 2 lines Add entry for issue #691291. ........
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 57420ff..7c3a30b 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"