summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-06 07:27:28 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-06 07:27:28 (GMT)
commit3dcb0cf9b195afc9d3a5c79f8b0a6cd755bc7bd0 (patch)
tree9f451d62b8a8349421e6b219c91e7025e3655b5a
parentbfafa6198affa9073f640d94508b70ff7766bacd (diff)
parent5b4fab1ad7382f45c848b85c6f94b08c212471bd (diff)
downloadcpython-3dcb0cf9b195afc9d3a5c79f8b0a6cd755bc7bd0.zip
cpython-3dcb0cf9b195afc9d3a5c79f8b0a6cd755bc7bd0.tar.gz
cpython-3dcb0cf9b195afc9d3a5c79f8b0a6cd755bc7bd0.tar.bz2
Issue #20520: Fixed readline test in test_codecs.
-rw-r--r--Lib/test/test_codecs.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 3950c3b..c04ffd7 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -148,19 +148,20 @@ class ReadTest(MixInCheckStateHandling):
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):
@@ -168,12 +169,20 @@ class ReadTest(MixInCheckStateHandling):
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",