Add unit tests for the newlines property of IncrementalNewlineDecoder.

This commit is contained in:
Alexandre Vassalotti 2008-01-06 00:34:32 +00:00
parent ab078ddb4f
commit 472f07d31a
1 changed files with 16 additions and 0 deletions

View File

@ -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):