summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-17 02:40:13 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-17 02:40:13 (GMT)
commitc10c34d6cb0d06632c7706a16cb3d448e0c3cfce (patch)
treea6f9089c6f1bcf50e2e4c92811f16dd57c0687e7 /Lib
parentfdaa3a303db5f353e1c1a3f599a3a5049b693003 (diff)
downloadcpython-c10c34d6cb0d06632c7706a16cb3d448e0c3cfce.zip
cpython-c10c34d6cb0d06632c7706a16cb3d448e0c3cfce.tar.gz
cpython-c10c34d6cb0d06632c7706a16cb3d448e0c3cfce.tar.bz2
Make test_io faster
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_io.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index e8bba86..489e560 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1021,6 +1021,10 @@ class TextIOWrapperTest(unittest.TestCase):
def testSeekAndTell(self):
"""Test seek/tell using the StatefulIncrementalDecoder."""
+ # Make this test faster by forcing a smaller (but large enough)
+ # chunk size. The bigger the chunker size, the slower seek() is,
+ # as it tries to replay character decoding one byte at a time.
+ CHUNK_SIZE = 256
def testSeekAndTellWithData(data, min_pos=0):
"""Tell/seek to various points within a data stream and ensure
@@ -1035,6 +1039,7 @@ class TextIOWrapperTest(unittest.TestCase):
for i in range(min_pos, len(decoded) + 1): # seek positions
for j in [1, 5, len(decoded) - i]: # read lengths
f = io.open(support.TESTFN, encoding='test_decoder')
+ f._CHUNK_SIZE = CHUNK_SIZE
self.assertEquals(f.read(i), decoded[:i])
cookie = f.tell()
self.assertEquals(f.read(j), decoded[i:i + j])
@@ -1052,7 +1057,6 @@ class TextIOWrapperTest(unittest.TestCase):
testSeekAndTellWithData(input)
# Position each test case so that it crosses a chunk boundary.
- CHUNK_SIZE = io.TextIOWrapper._CHUNK_SIZE
for input, _, _ in StatefulIncrementalDecoderTest.test_cases:
offset = CHUNK_SIZE - len(input)//2
prefix = b'.'*offset