From: Alexandre Vassalotti Date: Sun, 6 Jan 2008 00:34:32 +0000 (+0000) Subject: Add unit tests for the newlines property of IncrementalNewlineDecoder. X-Git-Tag: v3.0a3~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=472f07d31a1b78376f8f5d86863025617ca84132;p=thirdparty%2FPython%2Fcpython.git Add unit tests for the newlines property of IncrementalNewlineDecoder. --- diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 87e871bc9349..33b32e0a1bba 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -911,6 +911,22 @@ class TextIOWrapperTest(unittest.TestCase): 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):