Skip to content

Commit

Permalink
Some more test-size-estimate fixes: test_append and test_insert trigg…
Browse files Browse the repository at this point in the history
…er a

list resize, which overallocates.
  • Loading branch information
Yhg1s committed Apr 26, 2006
1 parent cda404b commit b5ccd14
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Lib/test/test_bigmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,9 @@ def test_repr_small(self, size):
def test_repr_large(self, size):
return self.basic_test_repr(size)


@bigmemtest(minsize=_2G, memuse=8)
# list overallocates ~1/8th of the total size (on first expansion) so
# the single list.append call puts memuse at 9 bytes per size.
@bigmemtest(minsize=_2G, memuse=9)
def test_append(self, size):
l = [object()] * size
l.append(object())
Expand Down Expand Up @@ -872,7 +873,8 @@ def test_index(self, size):
self.assertRaises(ValueError, l.index, 1, size - 4, size)
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):
l = [1.0] * size
l.insert(size - 1, "A")
Expand Down Expand Up @@ -920,6 +922,8 @@ def test_remove(self, size):
size -= 1
self.assertEquals(len(l), size)

# Because of the earlier l.remove(), this append doesn't trigger
# a resize.
l.append(5)
size += 1
self.assertEquals(len(l), size)
Expand Down

0 comments on commit b5ccd14

Please sign in to comment.