diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-01-06 00:34:32 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-01-06 00:34:32 (GMT) |
commit | 472f07d31a1b78376f8f5d86863025617ca84132 (patch) | |
tree | 6c4e522796a776d95074eba8506e2ccc3dc5a401 | |
parent | ab078ddb4f8a7ac68f54a3c7f110f4d82e82b16f (diff) | |
download | cpython-472f07d31a1b78376f8f5d86863025617ca84132.zip cpython-472f07d31a1b78376f8f5d86863025617ca84132.tar.gz cpython-472f07d31a1b78376f8f5d86863025617ca84132.tar.bz2 |
Add unit tests for the newlines property of IncrementalNewlineDecoder.
-rw-r--r-- | Lib/test/test_io.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 87e871b..33b32e0 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): |