[Python-3000-checkins] r59762 - python/branches/py3k/Lib/test/test_io.py
alexandre.vassalotti
python-3000-checkins at python.org
Sun Jan 6 01:34:32 CET 2008
Author: alexandre.vassalotti
Date: Sun Jan 6 01:34:32 2008
New Revision: 59762
Modified:
python/branches/py3k/Lib/test/test_io.py
Log:
Add unit tests for the newlines property of IncrementalNewlineDecoder.
Modified: python/branches/py3k/Lib/test/test_io.py
==============================================================================
--- python/branches/py3k/Lib/test/test_io.py (original)
+++ python/branches/py3k/Lib/test/test_io.py Sun Jan 6 01:34:32 2008
@@ -911,6 +911,22 @@
self.assertEquals(decoder.decode(b'\xe8\xa2\x88\r'), "\u8888")
self.assertEquals(decoder.decode(b'\n'), "\n")
+ decoder = codecs.getincrementaldecoder("utf-8")()
+ decoder = io.IncrementalNewlineDecoder(decoder, translate=True)
+ self.assertEquals(decoder.newlines, None)
+ decoder.decode(b"abc\n\r")
+ self.assertEquals(decoder.newlines, '\n')
+ decoder.decode(b"\nabc")
+ self.assertEquals(decoder.newlines, ('\n', '\r\n'))
+ decoder.decode(b"abc\r")
+ self.assertEquals(decoder.newlines, ('\n', '\r\n'))
+ decoder.decode(b"abc")
+ self.assertEquals(decoder.newlines, ('\r', '\n', '\r\n'))
+ decoder.decode(b"abc\r")
+ decoder.reset()
+ self.assertEquals(decoder.decode(b"abc"), "abc")
+ self.assertEquals(decoder.newlines, None)
+
# XXX Tests for open()
class MiscIOTest(unittest.TestCase):
More information about the Python-3000-checkins
mailing list