mirror of https://github.com/python/cpython.git
Newly enabled test appears to leak:
it registers the same codec on each iteration. Do it only once at load time.
This commit is contained in:
parent
ce6f6c12c6
commit
f0a49708eb
|
@ -574,6 +574,22 @@ def process_word(self):
|
||||||
self.buffer = bytearray()
|
self.buffer = bytearray()
|
||||||
return output
|
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):
|
class StatefulIncrementalDecoderTest(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
Make sure the StatefulIncrementalDecoder actually works.
|
Make sure the StatefulIncrementalDecoder actually works.
|
||||||
|
@ -898,14 +914,6 @@ def testSeekingToo(self):
|
||||||
def testSeekAndTell(self):
|
def testSeekAndTell(self):
|
||||||
"""Test seek/tell using the StatefulIncrementalDecoder."""
|
"""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):
|
def testSeekAndTellWithData(data, min_pos=0):
|
||||||
"""Tell/seek to various points within a data stream and ensure
|
"""Tell/seek to various points within a data stream and ensure
|
||||||
that the decoded data returned by read() is consistent."""
|
that the decoded data returned by read() is consistent."""
|
||||||
|
@ -926,9 +934,8 @@ def testSeekAndTellWithData(data, min_pos=0):
|
||||||
self.assertEquals(f.read(), decoded[i:])
|
self.assertEquals(f.read(), decoded[i:])
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Register a special incremental decoder for testing.
|
# Enable the test decoder.
|
||||||
codecs.register(lookupTestDecoder)
|
StatefulIncrementalDecoder.codecEnabled = 1
|
||||||
self.codecEnabled = 1
|
|
||||||
|
|
||||||
# Run the tests.
|
# Run the tests.
|
||||||
try:
|
try:
|
||||||
|
@ -947,7 +954,7 @@ def testSeekAndTellWithData(data, min_pos=0):
|
||||||
|
|
||||||
# Ensure our test decoder won't interfere with subsequent tests.
|
# Ensure our test decoder won't interfere with subsequent tests.
|
||||||
finally:
|
finally:
|
||||||
self.codecEnabled = 0
|
StatefulIncrementalDecoder.codecEnabled = 0
|
||||||
|
|
||||||
def testEncodedWrites(self):
|
def testEncodedWrites(self):
|
||||||
data = u"1234567890"
|
data = u"1234567890"
|
||||||
|
|
Loading…
Reference in New Issue