diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-12 20:46:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-12 20:46:37 (GMT) |
commit | 45545f79c94460dbfe18b22116f6294468dd09c9 (patch) | |
tree | aeec0b92cf8c57e6705edbb12c7039028af77ac0 /Lib | |
parent | b3d89a4ee438ee6927bfe553694b5b06f5672274 (diff) | |
download | cpython-45545f79c94460dbfe18b22116f6294468dd09c9.zip cpython-45545f79c94460dbfe18b22116f6294468dd09c9.tar.gz cpython-45545f79c94460dbfe18b22116f6294468dd09c9.tar.bz2 |
Fix the expected memory use of utf-8 encoding. Also, release the
one reference to a huge object even when an exception is raised.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_bigmem.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py index e2b5521..ac6b109 100644 --- a/Lib/test/test_bigmem.py +++ b/Lib/test/test_bigmem.py @@ -564,8 +564,11 @@ class StrTest(unittest.TestCase, BaseStrTest): if expectedsize is None: expectedsize = size - s = c * size - self.assertEqual(len(s.encode(enc)), expectedsize) + try: + s = c * size + self.assertEqual(len(s.encode(enc)), expectedsize) + finally: + s = None def setUp(self): # HACK: adjust memory use of tests inherited from BaseStrTest @@ -586,7 +589,8 @@ class StrTest(unittest.TestCase, BaseStrTest): for name, memuse in self._adjusted.items(): getattr(type(self), name).memuse = memuse - @bigmemtest(minsize=_2G + 2, memuse=character_size + 1) + # the utf8 encoder preallocates big time (4x the number of characters) + @bigmemtest(minsize=_2G + 2, memuse=character_size + 4) def test_encode(self, size): return self.basic_encode_test(size, 'utf-8') |