from test import support
-from test.support import bigmemtest, _1G, _2G, _4G, precisionbigmemtest
+from test.support import bigmemtest, _1G, _2G, _4G
import unittest
import operator
# a large object, make the subobject of a length that is not a power of
# 2. That way, int-wrapping problems are more easily detected.
#
-# - While the bigmemtest decorator speaks of 'minsize', all tests will
-# actually be called with a much smaller number too, in the normal
-# test run (5Kb currently.) This is so the tests themselves get frequent
-# testing. Consequently, always make all large allocations based on the
+# - Despite the bigmemtest decorator, all tests will actually be called
+# with a much smaller number too, in the normal test run (5Kb currently.)
+# This is so the tests themselves get frequent testing.
+# Consequently, always make all large allocations based on the
# passed-in 'size', and don't rely on the size being very large. Also,
# memuse-per-size should remain sane (less than a few thousand); if your
# test uses more, adjust 'size' upward, instead.
class BaseStrTest:
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_capitalize(self, size):
_ = self.from_latin1
SUBSTR = self.from_latin1(' abc def ghi')
SUBSTR.capitalize())
self.assertEqual(caps.lstrip(_('-')), SUBSTR)
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_center(self, size):
SUBSTR = self.from_latin1(' abc def ghi')
s = SUBSTR.center(size)
self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_count(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
self.assertEqual(s.count(_('i')), 1)
self.assertEqual(s.count(_('j')), 0)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_endswith(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
self.assertFalse(s.endswith(_('a') + SUBSTR))
self.assertFalse(SUBSTR.endswith(s))
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_expandtabs(self, size):
_ = self.from_latin1
s = _('-') * size
self.assertEqual(len(s), size - remainder)
self.assertEqual(len(s.strip(_(' '))), 0)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_find(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
sublen + size + SUBSTR.find(_('i')))
self.assertEqual(s.find(_('j')), -1)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_index(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
sublen + size + SUBSTR.index(_('i')))
self.assertRaises(ValueError, s.index, _('j'))
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isalnum(self, size):
_ = self.from_latin1
SUBSTR = _('123456')
s += _('.')
self.assertFalse(s.isalnum())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isalpha(self, size):
_ = self.from_latin1
SUBSTR = _('zzzzzzz')
s += _('.')
self.assertFalse(s.isalpha())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isdigit(self, size):
_ = self.from_latin1
SUBSTR = _('123456')
s += _('z')
self.assertFalse(s.isdigit())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_islower(self, size):
_ = self.from_latin1
chars = _(''.join(
s += _('A')
self.assertFalse(s.islower())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isspace(self, size):
_ = self.from_latin1
whitespace = _(' \f\n\r\t\v')
s += _('j')
self.assertFalse(s.isspace())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_istitle(self, size):
_ = self.from_latin1
SUBSTR = _('123456')
s += _('aA')
self.assertFalse(s.istitle())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isupper(self, size):
_ = self.from_latin1
chars = _(''.join(
s += _('a')
self.assertFalse(s.isupper())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_join(self, size):
_ = self.from_latin1
s = _('A') * size
self.assertTrue(x.startswith(_('aaaaaA')))
self.assertTrue(x.endswith(_('Abbbbb')))
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_ljust(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_lower(self, size):
_ = self.from_latin1
s = _('A') * size
self.assertEqual(len(s), size)
self.assertEqual(s.count(_('a')), size)
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_lstrip(self, size):
_ = self.from_latin1
SUBSTR = _('abc def ghi')
stripped = s.lstrip()
self.assertTrue(stripped is s)
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_replace(self, size):
_ = self.from_latin1
replacement = _('a')
self.assertEqual(s.count(replacement), 4)
self.assertEqual(s[-10:], _(' aaaa'))
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_rfind(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
SUBSTR.rfind(_('i')))
self.assertEqual(s.rfind(_('j')), -1)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_rindex(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
SUBSTR.rindex(_('i')))
self.assertRaises(ValueError, s.rindex, _('j'))
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_rjust(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_rstrip(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
# The test takes about size bytes to build a string, and then about
# sqrt(size) substrings of sqrt(size) in size and a list to
# hold sqrt(size) items. It's close but just over 2x size.
- @bigmemtest(minsize=_2G, memuse=2.1)
+ @bigmemtest(size=_2G, memuse=2.1)
def test_split_small(self, size):
_ = self.from_latin1
# Crudely calculate an estimate so that the result of s.split won't
# suffer for the list size. (Otherwise, it'd cost another 48 times
# size in bytes!) Nevertheless, a list of size takes
# 8*size bytes.
- @bigmemtest(minsize=_2G + 5, memuse=10)
+ @bigmemtest(size=_2G + 5, memuse=10)
def test_split_large(self, size):
_ = self.from_latin1
s = _(' a') * size + _(' ')
self.assertEqual(len(l), size + 1)
self.assertEqual(set(l), set([_(' ')]))
- @bigmemtest(minsize=_2G, memuse=2.1)
+ @bigmemtest(size=_2G, memuse=2.1)
def test_splitlines(self, size):
_ = self.from_latin1
# Crudely calculate an estimate so that the result of s.split won't
for item in l:
self.assertEqual(item, expected)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_startswith(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
self.assertTrue(s.startswith(_('-') * size))
self.assertFalse(s.startswith(SUBSTR))
- @bigmemtest(minsize=_2G, memuse=1)
+ @bigmemtest(size=_2G, memuse=1)
def test_strip(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi ')
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_swapcase(self, size):
_ = self.from_latin1
SUBSTR = _("aBcDeFG12.'\xa9\x00")
self.assertEqual(s[:sublen * 3], SUBSTR.swapcase() * 3)
self.assertEqual(s[-sublen * 3:], SUBSTR.swapcase() * 3)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_title(self, size):
_ = self.from_latin1
SUBSTR = _('SpaaHAaaAaham')
self.assertTrue(s.startswith((SUBSTR * 3).title()))
self.assertTrue(s.endswith(SUBSTR.lower() * 3))
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_translate(self, size):
_ = self.from_latin1
SUBSTR = _('aZz.z.Aaz.')
self.assertEqual(s.count(_('!')), repeats * 2)
self.assertEqual(s.count(_('z')), repeats * 3)
- @bigmemtest(minsize=_2G + 5, memuse=2)
+ @bigmemtest(size=_2G + 5, memuse=2)
def test_upper(self, size):
_ = self.from_latin1
s = _('a') * size
self.assertEqual(len(s), size)
self.assertEqual(s.count(_('A')), size)
- @bigmemtest(minsize=_2G + 20, memuse=1)
+ @bigmemtest(size=_2G + 20, memuse=1)
def test_zfill(self, size):
_ = self.from_latin1
SUBSTR = _('-568324723598234')
# This test is meaningful even with size < 2G, as long as the
# doubled string is > 2G (but it tests more if both are > 2G :)
- @bigmemtest(minsize=_1G + 2, memuse=3)
+ @bigmemtest(size=_1G + 2, memuse=3)
def test_concat(self, size):
_ = self.from_latin1
s = _('.') * size
# This test is meaningful even with size < 2G, as long as the
# repeated string is > 2G (but it tests more if both are > 2G :)
- @bigmemtest(minsize=_1G + 2, memuse=3)
+ @bigmemtest(size=_1G + 2, memuse=3)
def test_repeat(self, size):
_ = self.from_latin1
s = _('.') * size
self.assertEqual(len(s), size * 2)
self.assertEqual(s.count(_('.')), size * 2)
- @bigmemtest(minsize=_2G + 20, memuse=2)
+ @bigmemtest(size=_2G + 20, memuse=2)
def test_slice_and_getitem(self, size):
_ = self.from_latin1
SUBSTR = _('0123456789')
self.assertRaises(IndexError, operator.getitem, s, len(s) + 1)
self.assertRaises(IndexError, operator.getitem, s, len(s) + 1<<31)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_contains(self, size):
_ = self.from_latin1
SUBSTR = _('0123456789')
s += _('a')
self.assertIn(_('a'), s)
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_compare(self, size):
_ = self.from_latin1
s1 = _('-') * size
s2 = _('.') * size
self.assertFalse(s1 == s2)
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_hash(self, size):
# Not sure if we can do any meaningful tests here... Even if we
# start relying on the exact algorithm used, the result will be
getattr(type(self), name).memuse = memuse
# the utf8 encoder preallocates big time (4x the number of characters)
- @bigmemtest(minsize=_2G + 2, memuse=character_size + 4)
+ @bigmemtest(size=_2G + 2, memuse=character_size + 4)
def test_encode(self, size):
return self.basic_encode_test(size, 'utf-8')
- @precisionbigmemtest(size=_4G // 6 + 2, memuse=character_size + 1)
+ @bigmemtest(size=_4G // 6 + 2, memuse=character_size + 1)
def test_encode_raw_unicode_escape(self, size):
try:
return self.basic_encode_test(size, 'raw_unicode_escape')
except MemoryError:
pass # acceptable on 32-bit
- @precisionbigmemtest(size=_4G // 5 + 70, memuse=character_size + 1)
+ @bigmemtest(size=_4G // 5 + 70, memuse=character_size + 1)
def test_encode_utf7(self, size):
try:
return self.basic_encode_test(size, 'utf7')
except MemoryError:
pass # acceptable on 32-bit
- @precisionbigmemtest(size=_4G // 4 + 5, memuse=character_size + 4)
+ @bigmemtest(size=_4G // 4 + 5, memuse=character_size + 4)
def test_encode_utf32(self, size):
try:
return self.basic_encode_test(size, 'utf32', expectedsize=4*size+4)
except MemoryError:
pass # acceptable on 32-bit
- @precisionbigmemtest(size=_2G - 1, memuse=character_size + 1)
+ @bigmemtest(size=_2G - 1, memuse=character_size + 1)
def test_encode_ascii(self, size):
return self.basic_encode_test(size, 'ascii', c='A')
- @precisionbigmemtest(size=_4G // 5, memuse=character_size * (6 + 1))
- def test_unicode_repr_overflow(self, size):
- try:
- s = "\uDCBA"*size
- r = repr(s)
- except MemoryError:
- pass # acceptable on 32-bit
- else:
- self.assertTrue(s == eval(r))
-
- @bigmemtest(minsize=_2G + 10, memuse=character_size * 2)
+ @bigmemtest(size=_2G + 10, memuse=character_size * 2)
def test_format(self, size):
s = '-' * size
sf = '%s' % (s,)
self.assertEqual(s.count('.'), 3)
self.assertEqual(s.count('-'), size * 2)
- @bigmemtest(minsize=_2G + 10, memuse=character_size * 2)
+ @bigmemtest(size=_2G + 10, memuse=character_size * 2)
def test_repr_small(self, size):
s = '-' * size
s = repr(s)
self.assertEqual(s.count('\\'), size)
self.assertEqual(s.count('0'), size * 2)
- @bigmemtest(minsize=_2G + 10, memuse=character_size * 5)
+ @bigmemtest(size=_2G + 10, memuse=character_size * 5)
def test_repr_large(self, size):
s = '\x00' * size
s = repr(s)
self.assertEqual(s.count('\\'), size)
self.assertEqual(s.count('0'), size * 2)
- @bigmemtest(minsize=2**32 / 5, memuse=character_size * 7)
+ @bigmemtest(size=_2G // 5 + 1, memuse=character_size * 7)
def test_unicode_repr(self, size):
# Use an assigned, but not printable code point.
# It is in the range of the low surrogates \uDC00-\uDFFF.
- s = "\uDCBA" * size
- for f in (repr, ascii):
- r = f(s)
- self.assertTrue(len(r) > size)
- self.assertTrue(r.endswith(r"\udcba'"), r[-10:])
- del r
+ char = "\uDCBA"
+ s = char * size
+ try:
+ for f in (repr, ascii):
+ r = f(s)
+ self.assertEqual(len(r), 2 + (len(f(char)) - 2) * size)
+ self.assertTrue(r.endswith(r"\udcba'"), r[-10:])
+ r = None
+ finally:
+ r = s = None
# The character takes 4 bytes even in UCS-2 builds because it will
# be decomposed into surrogates.
- @bigmemtest(minsize=2**32 / 5, memuse=4 + character_size * 9)
+ @bigmemtest(size=_2G // 5 + 1, memuse=4 + character_size * 9)
def test_unicode_repr_wide(self, size):
- s = "\U0001DCBA" * size
- for f in (repr, ascii):
- r = f(s)
- self.assertTrue(len(r) > size)
- self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:])
- del r
+ char = "\U0001DCBA"
+ s = char * size
+ try:
+ for f in (repr, ascii):
+ r = f(s)
+ self.assertEqual(len(r), 2 + (len(f(char)) - 2) * size)
+ self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:])
+ r = None
+ finally:
+ r = s = None
+
+ @bigmemtest(size=_4G // 5, memuse=character_size * (6 + 1))
+ def _test_unicode_repr_overflow(self, size):
+ # XXX not sure what this test is about
+ char = "\uDCBA"
+ s = char * size
+ try:
+ r = repr(s)
+ self.assertTrue(s == eval(r))
+ finally:
+ r = s = None
class BytesTest(unittest.TestCase, BaseStrTest):
def from_latin1(self, s):
return s.encode("latin1")
- @bigmemtest(minsize=_2G + 2, memuse=1 + character_size)
+ @bigmemtest(size=_2G + 2, memuse=1 + character_size)
def test_decode(self, size):
s = self.from_latin1('.') * size
self.assertEqual(len(s.decode('utf-8')), size)
def from_latin1(self, s):
return bytearray(s.encode("latin1"))
- @bigmemtest(minsize=_2G + 2, memuse=1 + character_size)
+ @bigmemtest(size=_2G + 2, memuse=1 + character_size)
def test_decode(self, size):
s = self.from_latin1('.') * size
self.assertEqual(len(s.decode('utf-8')), size)
# having more than 2<<31 references to any given object. Hence the
# use of different types of objects as contents in different tests.
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_compare(self, size):
t1 = ('',) * size
t2 = ('',) * size
t = t + t
self.assertEqual(len(t), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_concat_small(self, size):
return self.basic_concat_test(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_concat_large(self, size):
return self.basic_concat_test(size)
- @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 10, memuse=8 * 5)
def test_contains(self, size):
t = (1, 2, 3, 4, 5) * size
self.assertEqual(len(t), size * 5)
self.assertNotIn((1, 2, 3, 4, 5), t)
self.assertNotIn(0, t)
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_hash(self, size):
t1 = (0,) * size
h1 = hash(t1)
t2 = (0,) * (size + 1)
self.assertFalse(h1 == hash(t2))
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
t = (None,) * size
self.assertEqual(len(t), size)
t = t * 2
self.assertEqual(len(t), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_repeat_small(self, size):
return self.basic_test_repeat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_repeat_large(self, size):
return self.basic_test_repeat(size)
- @bigmemtest(minsize=_1G - 1, memuse=12)
+ @bigmemtest(size=_1G - 1, memuse=12)
def test_repeat_large_2(self, size):
return self.basic_test_repeat(size)
- @precisionbigmemtest(size=_1G - 1, memuse=9)
+ @bigmemtest(size=_1G - 1, memuse=9)
def test_from_2G_generator(self, size):
self.skipTest("test needs much more memory than advertised, see issue5438")
try:
count += 1
self.assertEqual(count, size)
- @precisionbigmemtest(size=_1G - 25, memuse=9)
+ @bigmemtest(size=_1G - 25, memuse=9)
def test_from_almost_2G_generator(self, size):
self.skipTest("test needs much more memory than advertised, see issue5438")
try:
self.assertEqual(s[-5:], '0, 0)')
self.assertEqual(s.count('0'), size)
- @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3 * character_size)
+ @bigmemtest(size=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
return self.basic_test_repr(size)
- @bigmemtest(minsize=_2G + 2, memuse=8 + 3 * character_size)
+ @bigmemtest(size=_2G + 2, memuse=8 + 3 * character_size)
def test_repr_large(self, size):
return self.basic_test_repr(size)
# lists hold references to various objects to test their refcount
# limits.
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_compare(self, size):
l1 = [''] * size
l2 = [''] * size
l = l + l
self.assertEqual(len(l), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_concat_small(self, size):
return self.basic_test_concat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_concat_large(self, size):
return self.basic_test_concat(size)
self.assertTrue(l[0] is l[-1])
self.assertTrue(l[size - 1] is l[size + 1])
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_inplace_concat_small(self, size):
return self.basic_test_inplace_concat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_inplace_concat_large(self, size):
return self.basic_test_inplace_concat(size)
- @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 10, memuse=8 * 5)
def test_contains(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEqual(len(l), size * 5)
self.assertNotIn([1, 2, 3, 4, 5], l)
self.assertNotIn(0, l)
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_hash(self, size):
l = [0] * size
self.assertRaises(TypeError, hash, l)
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
l = [None] * size
self.assertEqual(len(l), size)
l = l * 2
self.assertEqual(len(l), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_repeat_small(self, size):
return self.basic_test_repeat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_repeat_large(self, size):
return self.basic_test_repeat(size)
self.assertEqual(len(l), size * 2)
self.assertTrue(l[size - 1] is l[-1])
- @bigmemtest(minsize=_2G // 2 + 2, memuse=16)
+ @bigmemtest(size=_2G // 2 + 2, memuse=16)
def test_inplace_repeat_small(self, size):
return self.basic_test_inplace_repeat(size)
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_inplace_repeat_large(self, size):
return self.basic_test_inplace_repeat(size)
self.assertEqual(s[-5:], '0, 0]')
self.assertEqual(s.count('0'), size)
- @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3 * character_size)
+ @bigmemtest(size=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
return self.basic_test_repr(size)
- @bigmemtest(minsize=_2G + 2, memuse=8 + 3 * character_size)
+ @bigmemtest(size=_2G + 2, memuse=8 + 3 * character_size)
def test_repr_large(self, size):
return self.basic_test_repr(size)
# 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)
+ @bigmemtest(size=_2G, memuse=9)
def test_append(self, size):
l = [object()] * size
l.append(object())
self.assertTrue(l[-3] is l[-2])
self.assertFalse(l[-2] is l[-1])
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_count(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEqual(l.count(1), size)
self.assertTrue(l[0] is l[-1])
self.assertTrue(l[size - 1] is l[size + 1])
- @bigmemtest(minsize=_2G // 2 + 2, memuse=16)
+ @bigmemtest(size=_2G // 2 + 2, memuse=16)
def test_extend_small(self, size):
return self.basic_test_extend(size)
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_extend_large(self, size):
return self.basic_test_extend(size)
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_index(self, size):
l = [1, 2, 3, 4, 5] * size
size *= 5
self.assertRaises(ValueError, l.index, 6)
# This tests suffers from overallocation, just like test_append.
- @bigmemtest(minsize=_2G + 10, memuse=9)
+ @bigmemtest(size=_2G + 10, memuse=9)
def test_insert(self, size):
l = [1.0] * size
l.insert(size - 1, "A")
self.assertEqual(l[:3], [1.0, "C", 1.0])
self.assertEqual(l[size - 3:], ["A", 1.0, "B"])
- @bigmemtest(minsize=_2G // 5 + 4, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 4, memuse=8 * 5)
def test_pop(self, size):
l = ["a", "b", "c", "d", "e"] * size
size *= 5
self.assertEqual(item, "c")
self.assertEqual(l[-2:], ["b", "d"])
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_remove(self, size):
l = [10] * size
self.assertEqual(len(l), size)
self.assertEqual(len(l), size)
self.assertEqual(l[-2:], [10, 10])
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_reverse(self, size):
l = [1, 2, 3, 4, 5] * size
l.reverse()
self.assertEqual(l[-5:], [5, 4, 3, 2, 1])
self.assertEqual(l[:5], [5, 4, 3, 2, 1])
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_sort(self, size):
l = [1, 2, 3, 4, 5] * size
l.sort()