summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-04-02 21:49:44 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-04-02 21:49:44 (GMT)
commitad9d48d865706a76e86b8929be5f981971206657 (patch)
tree33152d98b8e431fccf0edc41dd363223213c2890 /Lib/test/test_io.py
parent84bea688c2a5fb1f4e816fccbd93a8a4037816ca (diff)
downloadcpython-ad9d48d865706a76e86b8929be5f981971206657.zip
cpython-ad9d48d865706a76e86b8929be5f981971206657.tar.gz
cpython-ad9d48d865706a76e86b8929be5f981971206657.tar.bz2
Merged revisions 62090-62091,62096,62100,62102,62110-62114 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r62090 | brett.cannon | 2008-04-01 07:37:43 -0500 (Tue, 01 Apr 2008) | 3 lines Generalize test.test_support.test_stdout() with a base context manager so that it is easy to capture stderr if desired. ........ r62091 | brett.cannon | 2008-04-01 07:46:02 -0500 (Tue, 01 Apr 2008) | 3 lines Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot of effort to do so. ........ r62096 | amaury.forgeotdarc | 2008-04-01 17:52:48 -0500 (Tue, 01 Apr 2008) | 4 lines Newly enabled test appears to leak: it registers the same codec on each iteration. Do it only once at load time. ........ r62100 | amaury.forgeotdarc | 2008-04-01 19:55:04 -0500 (Tue, 01 Apr 2008) | 4 lines A DocTestSuite cannot run multiple times: it clears its globals dictionary after the first run. Rebuild the DocTestSuite on each iteration. ........ r62102 | jeffrey.yasskin | 2008-04-01 23:07:44 -0500 (Tue, 01 Apr 2008) | 3 lines Try to make test_signal less flaky. I still see some flakiness in test_itimer_prof. ........ r62110 | vinay.sajip | 2008-04-02 16:09:27 -0500 (Wed, 02 Apr 2008) | 1 line Fix: #2315, #2316, #2317: TimedRotatingFileHandler - changed logic to better handle daylight savings time, deletion of old log files, and fixed a bug in calculating rollover when no logging occurs for a longer interval than the rollover period. ........ r62111 | vinay.sajip | 2008-04-02 16:10:23 -0500 (Wed, 02 Apr 2008) | 1 line Added updates with respect to recent changes to TimedRotatingFileHandler. ........ r62112 | vinay.sajip | 2008-04-02 16:17:25 -0500 (Wed, 02 Apr 2008) | 1 line Added updates with respect to recent changes to TimedRotatingFileHandler. ........ r62113 | amaury.forgeotdarc | 2008-04-02 16:18:46 -0500 (Wed, 02 Apr 2008) | 2 lines Remove debug prints; the buildbot now passes the tests ........ r62114 | benjamin.peterson | 2008-04-02 16:20:35 -0500 (Wed, 02 Apr 2008) | 2 lines Suggested proposed changes to Python be considered on some mailing lists first ........
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index f0e79312..0c37cc7 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -574,6 +574,22 @@ class StatefulIncrementalDecoder(codecs.IncrementalDecoder):
self.buffer = bytearray()
return output
+ codecEnabled = False
+
+ @classmethod
+ def lookupTestDecoder(cls, name):
+ if cls.codecEnabled and name == 'test_decoder':
+ return codecs.CodecInfo(
+ name='test_decoder', encode=None, decode=None,
+ incrementalencoder=None,
+ streamreader=None, streamwriter=None,
+ incrementaldecoder=cls)
+
+# Register the previous decoder for testing.
+# Disabled by default, tests will enable it.
+codecs.register(StatefulIncrementalDecoder.lookupTestDecoder)
+
+
class StatefulIncrementalDecoderTest(unittest.TestCase):
"""
Make sure the StatefulIncrementalDecoder actually works.
@@ -899,14 +915,6 @@ class TextIOWrapperTest(unittest.TestCase):
def testSeekAndTell(self):
"""Test seek/tell using the StatefulIncrementalDecoder."""
- def lookupTestDecoder(name):
- if self.codecEnabled and name == 'test_decoder':
- return codecs.CodecInfo(
- name='test_decoder', encode=None, decode=None,
- incrementalencoder=None,
- streamreader=None, streamwriter=None,
- incrementaldecoder=StatefulIncrementalDecoder)
-
def testSeekAndTellWithData(data, min_pos=0):
"""Tell/seek to various points within a data stream and ensure
that the decoded data returned by read() is consistent."""
@@ -927,9 +935,8 @@ class TextIOWrapperTest(unittest.TestCase):
self.assertEquals(f.read(), decoded[i:])
f.close()
- # Register a special incremental decoder for testing.
- codecs.register(lookupTestDecoder)
- self.codecEnabled = 1
+ # Enable the test decoder.
+ StatefulIncrementalDecoder.codecEnabled = 1
# Run the tests.
try:
@@ -948,7 +955,7 @@ class TextIOWrapperTest(unittest.TestCase):
# Ensure our test decoder won't interfere with subsequent tests.
finally:
- self.codecEnabled = 0
+ StatefulIncrementalDecoder.codecEnabled = 0
def testEncodedWrites(self):
data = "1234567890"