summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-08 13:12:43 +0000
committerChristian Heimes <christian@cheimes.de>2007-11-08 13:12:43 +0000
commit563e33b1923620f20114ab3ac51898d025580afb (patch)
tree8694d8c466de89b431e1847d4f871cee91a68c3e /Lib
parent7b6fc8e19de53fc354144d21b7a644d77ff60410 (diff)
downloadcpython-git-563e33b1923620f20114ab3ac51898d025580afb.tar.gz
Added tests from Raghuram Devarakonda for bug #1395 'py3k: duplicated line endings when using read(1)' to outstanding_bugs.py
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/outstanding_bugs.py70
1 files changed, 69 insertions, 1 deletions
diff --git a/Lib/test/outstanding_bugs.py b/Lib/test/outstanding_bugs.py
index 7c6cd9ef6b..9c75bfca9c 100644
--- a/Lib/test/outstanding_bugs.py
+++ b/Lib/test/outstanding_bugs.py
@@ -45,9 +45,77 @@ class TestDifflibLongestMatch(unittest.TestCase):
self.assertEquals(aptr, 1)
self.assertEquals(bptr, 0)
+# test_io
+import io
+class TextIOWrapperTest(unittest.TestCase):
+
+ def setUp(self):
+ self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n"
+ self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ASCII")
+
+ def tearDown(self):
+ test_support.unlink(test_support.TESTFN)
+
+
+ def test_issue1395_1(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+
+ # read one char at a time
+ reads = ""
+ while True:
+ c = txt.read(1)
+ if not c:
+ break
+ reads += c
+ self.assertEquals(reads, self.normalized)
+
+ def test_issue1395_2(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = ""
+ while True:
+ c = txt.read(4)
+ if not c:
+ break
+ reads += c
+ self.assertEquals(reads, self.normalized)
+
+ def test_issue1395_3(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = txt.read(4)
+ reads += txt.read(4)
+ reads += txt.readline()
+ reads += txt.readline()
+ reads += txt.readline()
+ self.assertEquals(reads, self.normalized)
+
+ def test_issue1395_4(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = txt.read(4)
+ reads += txt.read()
+ self.assertEquals(reads, self.normalized)
+
+ def test_issue1395_5(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = txt.read(4)
+ pos = txt.tell()
+ txt.seek(0)
+ txt.seek(pos)
+ self.assertEquals(txt.read(4), "BBB\n")
+
+
def test_main():
- test_support.run_unittest(TestDifflibLongestMatch)
+ test_support.run_unittest(
+ TestDifflibLongestMatch,
+ TextIOWrapperTest)
if __name__ == "__main__":
test_main()