mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Some more test-size-estimate fixes: test_append and test_insert trigger a
list resize, which overallocates.
This commit is contained in:
parent
cda404bf36
commit
b5ccd1416e
1 changed files with 7 additions and 3 deletions
|
|
@ -833,8 +833,9 @@ class ListTest(unittest.TestCase):
|
||||||
def test_repr_large(self, size):
|
def test_repr_large(self, size):
|
||||||
return self.basic_test_repr(size)
|
return self.basic_test_repr(size)
|
||||||
|
|
||||||
|
# list overallocates ~1/8th of the total size (on first expansion) so
|
||||||
@bigmemtest(minsize=_2G, memuse=8)
|
# the single list.append call puts memuse at 9 bytes per size.
|
||||||
|
@bigmemtest(minsize=_2G, memuse=9)
|
||||||
def test_append(self, size):
|
def test_append(self, size):
|
||||||
l = [object()] * size
|
l = [object()] * size
|
||||||
l.append(object())
|
l.append(object())
|
||||||
|
|
@ -872,7 +873,8 @@ class ListTest(unittest.TestCase):
|
||||||
self.assertRaises(ValueError, l.index, 1, size - 4, size)
|
self.assertRaises(ValueError, l.index, 1, size - 4, size)
|
||||||
self.assertRaises(ValueError, l.index, 6L)
|
self.assertRaises(ValueError, l.index, 6L)
|
||||||
|
|
||||||
@bigmemtest(minsize=_2G + 10, memuse=8)
|
# This tests suffers from overallocation, just like test_append.
|
||||||
|
@bigmemtest(minsize=_2G + 10, memuse=9)
|
||||||
def test_insert(self, size):
|
def test_insert(self, size):
|
||||||
l = [1.0] * size
|
l = [1.0] * size
|
||||||
l.insert(size - 1, "A")
|
l.insert(size - 1, "A")
|
||||||
|
|
@ -920,6 +922,8 @@ class ListTest(unittest.TestCase):
|
||||||
size -= 1
|
size -= 1
|
||||||
self.assertEquals(len(l), size)
|
self.assertEquals(len(l), size)
|
||||||
|
|
||||||
|
# Because of the earlier l.remove(), this append doesn't trigger
|
||||||
|
# a resize.
|
||||||
l.append(5)
|
l.append(5)
|
||||||
size += 1
|
size += 1
|
||||||
self.assertEquals(len(l), size)
|
self.assertEquals(len(l), size)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue