[Python-checkins] cpython (3.3): Issue #20520: Fixed readline test in test_codecs.

serhiy.storchaka python-checkins at python.org
Thu Feb 6 08:28:03 CET 2014


http://hg.python.org/cpython/rev/82d374a9bbc7
changeset:   88989:82d374a9bbc7
branch:      3.3
parent:      88984:6616c94d6149
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Thu Feb 06 09:26:56 2014 +0200
summary:
  Issue #20520: Fixed readline test in test_codecs.

files:
  Lib/test/test_codecs.py |  21 +++++++++++++++------
  1 files changed, 15 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -146,19 +146,20 @@
         self.assertEqual(readalllines(s, True, 10), sexpected)
         self.assertEqual(readalllines(s, False, 10), sexpectednoends)
 
+        lineends = ("\n", "\r\n", "\r", "\u2028")
         # Test long lines (multiple calls to read() in readline())
         vw = []
         vwo = []
-        for (i, lineend) in enumerate("\n \r\n \r \u2028".split()):
-            vw.append((i*200)*"\3042" + lineend)
-            vwo.append((i*200)*"\3042")
-        self.assertEqual(readalllines("".join(vw), True), "".join(vw))
-        self.assertEqual(readalllines("".join(vw), False),"".join(vwo))
+        for (i, lineend) in enumerate(lineends):
+            vw.append((i*200+200)*"\u3042" + lineend)
+            vwo.append((i*200+200)*"\u3042")
+        self.assertEqual(readalllines("".join(vw), True), "|".join(vw))
+        self.assertEqual(readalllines("".join(vw), False), "|".join(vwo))
 
         # Test lines where the first read might end with \r, so the
         # reader has to look ahead whether this is a lone \r or a \r\n
         for size in range(80):
-            for lineend in "\n \r\n \r \u2028".split():
+            for lineend in lineends:
                 s = 10*(size*"a" + lineend + "xxx\n")
                 reader = getreader(s)
                 for i in range(10):
@@ -166,12 +167,20 @@
                         reader.readline(keepends=True),
                         size*"a" + lineend,
                     )
+                    self.assertEqual(
+                        reader.readline(keepends=True),
+                        "xxx\n",
+                    )
                 reader = getreader(s)
                 for i in range(10):
                     self.assertEqual(
                         reader.readline(keepends=False),
                         size*"a",
                     )
+                    self.assertEqual(
+                        reader.readline(keepends=False),
+                        "xxx",
+                    )
 
     def test_mixed_readline_and_read(self):
         lines = ["Humpty Dumpty sat on a wall,\n",

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list