summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bigmem.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_bigmem.py')
-rw-r--r--Lib/test/test_bigmem.py486
1 files changed, 243 insertions, 243 deletions
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
index c2357ee..e2b5521 100644
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -13,7 +13,7 @@ import functools
# doesn't release the old 's' (if it exists) until well after its new
# value has been created. Use 'del s' before the create_largestring call.
#
-# - Do *not* compare large objects using assertEquals or similar. It's a
+# - Do *not* compare large objects using assertEqual or similar. It's a
# lengthy operation and the errormessage will be utterly useless due to
# its size. To make sure whether a result has the right contents, better
# to use the strip or count methods, or compare meaningful slices.
@@ -48,32 +48,32 @@ class BaseStrTest:
SUBSTR = self.from_latin1(' abc def ghi')
s = _('-') * size + SUBSTR
caps = s.capitalize()
- self.assertEquals(caps[-len(SUBSTR):],
+ self.assertEqual(caps[-len(SUBSTR):],
SUBSTR.capitalize())
- self.assertEquals(caps.lstrip(_('-')), SUBSTR)
+ self.assertEqual(caps.lstrip(_('-')), SUBSTR)
@bigmemtest(minsize=_2G + 10, memuse=1)
def test_center(self, size):
SUBSTR = self.from_latin1(' abc def ghi')
s = SUBSTR.center(size)
- self.assertEquals(len(s), size)
+ self.assertEqual(len(s), size)
lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
if len(s) % 2:
lpadsize += 1
- self.assertEquals(s[lpadsize:-rpadsize], SUBSTR)
- self.assertEquals(s.strip(), SUBSTR.strip())
+ self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
+ self.assertEqual(s.strip(), SUBSTR.strip())
@bigmemtest(minsize=_2G, memuse=2)
def test_count(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
s = _('.') * size + SUBSTR
- self.assertEquals(s.count(_('.')), size)
+ self.assertEqual(s.count(_('.')), size)
s += _('.')
- self.assertEquals(s.count(_('.')), size + 1)
- self.assertEquals(s.count(_(' ')), 3)
- self.assertEquals(s.count(_('i')), 1)
- self.assertEquals(s.count(_('j')), 0)
+ self.assertEqual(s.count(_('.')), size + 1)
+ self.assertEqual(s.count(_(' ')), 3)
+ self.assertEqual(s.count(_('i')), 1)
+ self.assertEqual(s.count(_('j')), 0)
@bigmemtest(minsize=_2G, memuse=2)
def test_endswith(self, size):
@@ -92,13 +92,13 @@ class BaseStrTest:
_ = self.from_latin1
s = _('-') * size
tabsize = 8
- self.assertEquals(s.expandtabs(), s)
+ self.assertEqual(s.expandtabs(), s)
del s
slen, remainder = divmod(size, tabsize)
s = _(' \t') * slen
s = s.expandtabs(tabsize)
- self.assertEquals(len(s), size - remainder)
- self.assertEquals(len(s.strip(_(' '))), 0)
+ self.assertEqual(len(s), size - remainder)
+ self.assertEqual(len(s.strip(_(' '))), 0)
@bigmemtest(minsize=_2G, memuse=2)
def test_find(self, size):
@@ -106,16 +106,16 @@ class BaseStrTest:
SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
s = _('').join([SUBSTR, _('-') * size, SUBSTR])
- self.assertEquals(s.find(_(' ')), 0)
- self.assertEquals(s.find(SUBSTR), 0)
- self.assertEquals(s.find(_(' '), sublen), sublen + size)
- self.assertEquals(s.find(SUBSTR, len(SUBSTR)), sublen + size)
- self.assertEquals(s.find(_('i')), SUBSTR.find(_('i')))
- self.assertEquals(s.find(_('i'), sublen),
+ self.assertEqual(s.find(_(' ')), 0)
+ self.assertEqual(s.find(SUBSTR), 0)
+ self.assertEqual(s.find(_(' '), sublen), sublen + size)
+ self.assertEqual(s.find(SUBSTR, len(SUBSTR)), sublen + size)
+ self.assertEqual(s.find(_('i')), SUBSTR.find(_('i')))
+ self.assertEqual(s.find(_('i'), sublen),
sublen + size + SUBSTR.find(_('i')))
- self.assertEquals(s.find(_('i'), size),
+ self.assertEqual(s.find(_('i'), size),
sublen + size + SUBSTR.find(_('i')))
- self.assertEquals(s.find(_('j')), -1)
+ self.assertEqual(s.find(_('j')), -1)
@bigmemtest(minsize=_2G, memuse=2)
def test_index(self, size):
@@ -123,14 +123,14 @@ class BaseStrTest:
SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
s = _('').join([SUBSTR, _('-') * size, SUBSTR])
- self.assertEquals(s.index(_(' ')), 0)
- self.assertEquals(s.index(SUBSTR), 0)
- self.assertEquals(s.index(_(' '), sublen), sublen + size)
- self.assertEquals(s.index(SUBSTR, sublen), sublen + size)
- self.assertEquals(s.index(_('i')), SUBSTR.index(_('i')))
- self.assertEquals(s.index(_('i'), sublen),
+ self.assertEqual(s.index(_(' ')), 0)
+ self.assertEqual(s.index(SUBSTR), 0)
+ self.assertEqual(s.index(_(' '), sublen), sublen + size)
+ self.assertEqual(s.index(SUBSTR, sublen), sublen + size)
+ self.assertEqual(s.index(_('i')), SUBSTR.index(_('i')))
+ self.assertEqual(s.index(_('i'), sublen),
sublen + size + SUBSTR.index(_('i')))
- self.assertEquals(s.index(_('i'), size),
+ self.assertEqual(s.index(_('i'), size),
sublen + size + SUBSTR.index(_('i')))
self.assertRaises(ValueError, s.index, _('j'))
@@ -209,8 +209,8 @@ class BaseStrTest:
_ = self.from_latin1
s = _('A') * size
x = s.join([_('aaaaa'), _('bbbbb')])
- self.assertEquals(x.count(_('a')), 5)
- self.assertEquals(x.count(_('b')), 5)
+ self.assertEqual(x.count(_('a')), 5)
+ self.assertEqual(x.count(_('b')), 5)
self.assertTrue(x.startswith(_('aaaaaA')))
self.assertTrue(x.endswith(_('Abbbbb')))
@@ -220,27 +220,27 @@ class BaseStrTest:
SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
self.assertTrue(s.startswith(SUBSTR + _(' ')))
- self.assertEquals(len(s), size)
- self.assertEquals(s.strip(), SUBSTR.strip())
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.strip(), SUBSTR.strip())
@bigmemtest(minsize=_2G + 10, memuse=2)
def test_lower(self, size):
_ = self.from_latin1
s = _('A') * size
s = s.lower()
- self.assertEquals(len(s), size)
- self.assertEquals(s.count(_('a')), size)
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.count(_('a')), size)
@bigmemtest(minsize=_2G + 10, memuse=1)
def test_lstrip(self, size):
_ = self.from_latin1
SUBSTR = _('abc def ghi')
s = SUBSTR.rjust(size)
- self.assertEquals(len(s), size)
- self.assertEquals(s.lstrip(), SUBSTR.lstrip())
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.lstrip(), SUBSTR.lstrip())
del s
s = SUBSTR.ljust(size)
- self.assertEquals(len(s), size)
+ self.assertEqual(len(s), size)
# Type-specific optimization
if isinstance(s, (str, bytes)):
stripped = s.lstrip()
@@ -252,12 +252,12 @@ class BaseStrTest:
replacement = _('a')
s = _(' ') * size
s = s.replace(_(' '), replacement)
- self.assertEquals(len(s), size)
- self.assertEquals(s.count(replacement), size)
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.count(replacement), size)
s = s.replace(replacement, _(' '), size - 4)
- self.assertEquals(len(s), size)
- self.assertEquals(s.count(replacement), 4)
- self.assertEquals(s[-10:], _(' aaaa'))
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.count(replacement), 4)
+ self.assertEqual(s[-10:], _(' aaaa'))
@bigmemtest(minsize=_2G, memuse=2)
def test_rfind(self, size):
@@ -265,15 +265,15 @@ class BaseStrTest:
SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
s = _('').join([SUBSTR, _('-') * size, SUBSTR])
- self.assertEquals(s.rfind(_(' ')), sublen + size + SUBSTR.rfind(_(' ')))
- self.assertEquals(s.rfind(SUBSTR), sublen + size)
- self.assertEquals(s.rfind(_(' '), 0, size), SUBSTR.rfind(_(' ')))
- self.assertEquals(s.rfind(SUBSTR, 0, sublen + size), 0)
- self.assertEquals(s.rfind(_('i')), sublen + size + SUBSTR.rfind(_('i')))
- self.assertEquals(s.rfind(_('i'), 0, sublen), SUBSTR.rfind(_('i')))
- self.assertEquals(s.rfind(_('i'), 0, sublen + size),
- SUBSTR.rfind(_('i')))
- self.assertEquals(s.rfind(_('j')), -1)
+ self.assertEqual(s.rfind(_(' ')), sublen + size + SUBSTR.rfind(_(' ')))
+ self.assertEqual(s.rfind(SUBSTR), sublen + size)
+ self.assertEqual(s.rfind(_(' '), 0, size), SUBSTR.rfind(_(' ')))
+ self.assertEqual(s.rfind(SUBSTR, 0, sublen + size), 0)
+ self.assertEqual(s.rfind(_('i')), sublen + size + SUBSTR.rfind(_('i')))
+ self.assertEqual(s.rfind(_('i'), 0, sublen), SUBSTR.rfind(_('i')))
+ self.assertEqual(s.rfind(_('i'), 0, sublen + size),
+ SUBSTR.rfind(_('i')))
+ self.assertEqual(s.rfind(_('j')), -1)
@bigmemtest(minsize=_2G, memuse=2)
def test_rindex(self, size):
@@ -281,17 +281,17 @@ class BaseStrTest:
SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
s = _('').join([SUBSTR, _('-') * size, SUBSTR])
- self.assertEquals(s.rindex(_(' ')),
- sublen + size + SUBSTR.rindex(_(' ')))
- self.assertEquals(s.rindex(SUBSTR), sublen + size)
- self.assertEquals(s.rindex(_(' '), 0, sublen + size - 1),
- SUBSTR.rindex(_(' ')))
- self.assertEquals(s.rindex(SUBSTR, 0, sublen + size), 0)
- self.assertEquals(s.rindex(_('i')),
- sublen + size + SUBSTR.rindex(_('i')))
- self.assertEquals(s.rindex(_('i'), 0, sublen), SUBSTR.rindex(_('i')))
- self.assertEquals(s.rindex(_('i'), 0, sublen + size),
- SUBSTR.rindex(_('i')))
+ self.assertEqual(s.rindex(_(' ')),
+ sublen + size + SUBSTR.rindex(_(' ')))
+ self.assertEqual(s.rindex(SUBSTR), sublen + size)
+ self.assertEqual(s.rindex(_(' '), 0, sublen + size - 1),
+ SUBSTR.rindex(_(' ')))
+ self.assertEqual(s.rindex(SUBSTR, 0, sublen + size), 0)
+ self.assertEqual(s.rindex(_('i')),
+ sublen + size + SUBSTR.rindex(_('i')))
+ self.assertEqual(s.rindex(_('i'), 0, sublen), SUBSTR.rindex(_('i')))
+ self.assertEqual(s.rindex(_('i'), 0, sublen + size),
+ SUBSTR.rindex(_('i')))
self.assertRaises(ValueError, s.rindex, _('j'))
@bigmemtest(minsize=_2G + 10, memuse=1)
@@ -300,19 +300,19 @@ class BaseStrTest:
SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
self.assertTrue(s.startswith(SUBSTR + _(' ')))
- self.assertEquals(len(s), size)
- self.assertEquals(s.strip(), SUBSTR.strip())
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.strip(), SUBSTR.strip())
@bigmemtest(minsize=_2G + 10, memuse=1)
def test_rstrip(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
- self.assertEquals(len(s), size)
- self.assertEquals(s.rstrip(), SUBSTR.rstrip())
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.rstrip(), SUBSTR.rstrip())
del s
s = SUBSTR.rjust(size)
- self.assertEquals(len(s), size)
+ self.assertEqual(len(s), size)
# Type-specific optimization
if isinstance(s, (str, bytes)):
stripped = s.rstrip()
@@ -330,16 +330,16 @@ class BaseStrTest:
SUBSTR = _('a') + _(' ') * chunksize
s = SUBSTR * chunksize
l = s.split()
- self.assertEquals(len(l), chunksize)
+ self.assertEqual(len(l), chunksize)
expected = _('a')
for item in l:
- self.assertEquals(item, expected)
+ self.assertEqual(item, expected)
del l
l = s.split(_('a'))
- self.assertEquals(len(l), chunksize + 1)
+ self.assertEqual(len(l), chunksize + 1)
expected = _(' ') * chunksize
for item in filter(None, l):
- self.assertEquals(item, expected)
+ self.assertEqual(item, expected)
# Allocates a string of twice size (and briefly two) and a list of
# size. Because of internal affairs, the s.split() call produces a
@@ -352,12 +352,12 @@ class BaseStrTest:
_ = self.from_latin1
s = _(' a') * size + _(' ')
l = s.split()
- self.assertEquals(len(l), size)
- self.assertEquals(set(l), set([_('a')]))
+ self.assertEqual(len(l), size)
+ self.assertEqual(set(l), set([_('a')]))
del l
l = s.split(_('a'))
- self.assertEquals(len(l), size + 1)
- self.assertEquals(set(l), set([_(' ')]))
+ self.assertEqual(len(l), size + 1)
+ self.assertEqual(set(l), set([_(' ')]))
@bigmemtest(minsize=_2G, memuse=2.1)
def test_splitlines(self, size):
@@ -368,10 +368,10 @@ class BaseStrTest:
SUBSTR = _(' ') * chunksize + _('\n') + _(' ') * chunksize + _('\r\n')
s = SUBSTR * chunksize
l = s.splitlines()
- self.assertEquals(len(l), chunksize * 2)
+ self.assertEqual(len(l), chunksize * 2)
expected = _(' ') * chunksize
for item in l:
- self.assertEquals(item, expected)
+ self.assertEqual(item, expected)
@bigmemtest(minsize=_2G, memuse=2)
def test_startswith(self, size):
@@ -387,12 +387,12 @@ class BaseStrTest:
_ = self.from_latin1
SUBSTR = _(' abc def ghi ')
s = SUBSTR.rjust(size)
- self.assertEquals(len(s), size)
- self.assertEquals(s.strip(), SUBSTR.strip())
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.strip(), SUBSTR.strip())
del s
s = SUBSTR.ljust(size)
- self.assertEquals(len(s), size)
- self.assertEquals(s.strip(), SUBSTR.strip())
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.strip(), SUBSTR.strip())
@bigmemtest(minsize=_2G, memuse=2)
def test_swapcase(self, size):
@@ -402,9 +402,9 @@ class BaseStrTest:
repeats = size // sublen + 2
s = SUBSTR * repeats
s = s.swapcase()
- self.assertEquals(len(s), sublen * repeats)
- self.assertEquals(s[:sublen * 3], SUBSTR.swapcase() * 3)
- self.assertEquals(s[-sublen * 3:], SUBSTR.swapcase() * 3)
+ self.assertEqual(len(s), sublen * repeats)
+ self.assertEqual(s[:sublen * 3], SUBSTR.swapcase() * 3)
+ self.assertEqual(s[-sublen * 3:], SUBSTR.swapcase() * 3)
@bigmemtest(minsize=_2G, memuse=2)
def test_title(self, size):
@@ -431,20 +431,20 @@ class BaseStrTest:
repeats = size // sublen + 2
s = SUBSTR * repeats
s = s.translate(trans)
- self.assertEquals(len(s), repeats * sublen)
- self.assertEquals(s[:sublen], SUBSTR.translate(trans))
- self.assertEquals(s[-sublen:], SUBSTR.translate(trans))
- self.assertEquals(s.count(_('.')), 0)
- self.assertEquals(s.count(_('!')), repeats * 2)
- self.assertEquals(s.count(_('z')), repeats * 3)
+ self.assertEqual(len(s), repeats * sublen)
+ self.assertEqual(s[:sublen], SUBSTR.translate(trans))
+ self.assertEqual(s[-sublen:], SUBSTR.translate(trans))
+ self.assertEqual(s.count(_('.')), 0)
+ self.assertEqual(s.count(_('!')), repeats * 2)
+ self.assertEqual(s.count(_('z')), repeats * 3)
@bigmemtest(minsize=_2G + 5, memuse=2)
def test_upper(self, size):
_ = self.from_latin1
s = _('a') * size
s = s.upper()
- self.assertEquals(len(s), size)
- self.assertEquals(s.count(_('A')), size)
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.count(_('A')), size)
@bigmemtest(minsize=_2G + 20, memuse=1)
def test_zfill(self, size):
@@ -453,8 +453,8 @@ class BaseStrTest:
s = SUBSTR.zfill(size)
self.assertTrue(s.endswith(_('0') + SUBSTR[1:]))
self.assertTrue(s.startswith(_('-0')))
- self.assertEquals(len(s), size)
- self.assertEquals(s.count(_('0')), size - len(SUBSTR))
+ self.assertEqual(len(s), size)
+ self.assertEqual(s.count(_('0')), size - len(SUBSTR))
# This test is meaningful even with size < 2G, as long as the
# doubled string is > 2G (but it tests more if both are > 2G :)
@@ -462,10 +462,10 @@ class BaseStrTest:
def test_concat(self, size):
_ = self.from_latin1
s = _('.') * size
- self.assertEquals(len(s), size)
+ self.assertEqual(len(s), size)
s = s + s
- self.assertEquals(len(s), size * 2)
- self.assertEquals(s.count(_('.')), size * 2)
+ self.assertEqual(len(s), size * 2)
+ self.assertEqual(s.count(_('.')), size * 2)
# This test is meaningful even with size < 2G, as long as the
# repeated string is > 2G (but it tests more if both are > 2G :)
@@ -473,10 +473,10 @@ class BaseStrTest:
def test_repeat(self, size):
_ = self.from_latin1
s = _('.') * size
- self.assertEquals(len(s), size)
+ self.assertEqual(len(s), size)
s = s * 2
- self.assertEquals(len(s), size * 2)
- self.assertEquals(s.count(_('.')), size * 2)
+ self.assertEqual(len(s), size * 2)
+ self.assertEqual(s.count(_('.')), size * 2)
@bigmemtest(minsize=_2G + 20, memuse=2)
def test_slice_and_getitem(self, size):
@@ -487,26 +487,26 @@ class BaseStrTest:
stepsize = len(s) // 100
stepsize = stepsize - (stepsize % sublen)
for i in range(0, len(s) - stepsize, stepsize):
- self.assertEquals(s[i], SUBSTR[0])
- self.assertEquals(s[i:i + sublen], SUBSTR)
- self.assertEquals(s[i:i + sublen:2], SUBSTR[::2])
+ self.assertEqual(s[i], SUBSTR[0])
+ self.assertEqual(s[i:i + sublen], SUBSTR)
+ self.assertEqual(s[i:i + sublen:2], SUBSTR[::2])
if i > 0:
- self.assertEquals(s[i + sublen - 1:i - 1:-3],
- SUBSTR[sublen::-3])
+ self.assertEqual(s[i + sublen - 1:i - 1:-3],
+ SUBSTR[sublen::-3])
# Make sure we do some slicing and indexing near the end of the
# string, too.
- self.assertEquals(s[len(s) - 1], SUBSTR[-1])
- self.assertEquals(s[-1], SUBSTR[-1])
- self.assertEquals(s[len(s) - 10], SUBSTR[0])
- self.assertEquals(s[-sublen], SUBSTR[0])
- self.assertEquals(s[len(s):], _(''))
- self.assertEquals(s[len(s) - 1:], SUBSTR[-1:])
- self.assertEquals(s[-1:], SUBSTR[-1:])
- self.assertEquals(s[len(s) - sublen:], SUBSTR)
- self.assertEquals(s[-sublen:], SUBSTR)
- self.assertEquals(len(s[:]), len(s))
- self.assertEquals(len(s[:len(s) - 5]), len(s) - 5)
- self.assertEquals(len(s[5:-5]), len(s) - 10)
+ self.assertEqual(s[len(s) - 1], SUBSTR[-1])
+ self.assertEqual(s[-1], SUBSTR[-1])
+ self.assertEqual(s[len(s) - 10], SUBSTR[0])
+ self.assertEqual(s[-sublen], SUBSTR[0])
+ self.assertEqual(s[len(s):], _(''))
+ self.assertEqual(s[len(s) - 1:], SUBSTR[-1:])
+ self.assertEqual(s[-1:], SUBSTR[-1:])
+ self.assertEqual(s[len(s) - sublen:], SUBSTR)
+ self.assertEqual(s[-sublen:], SUBSTR)
+ self.assertEqual(len(s[:]), len(s))
+ self.assertEqual(len(s[:len(s) - 5]), len(s) - 5)
+ self.assertEqual(len(s[5:-5]), len(s) - 10)
self.assertRaises(IndexError, operator.getitem, s, len(s))
self.assertRaises(IndexError, operator.getitem, s, len(s) + 1)
@@ -565,7 +565,7 @@ class StrTest(unittest.TestCase, BaseStrTest):
expectedsize = size
s = c * size
- self.assertEquals(len(s.encode(enc)), expectedsize)
+ self.assertEqual(len(s.encode(enc)), expectedsize)
def setUp(self):
# HACK: adjust memory use of tests inherited from BaseStrTest
@@ -632,7 +632,7 @@ class StrTest(unittest.TestCase, BaseStrTest):
self.assertEqual(s, sf)
del sf
sf = '..%s..' % (s,)
- self.assertEquals(len(sf), len(s) + 4)
+ self.assertEqual(len(sf), len(s) + 4)
self.assertTrue(sf.startswith('..-'))
self.assertTrue(sf.endswith('-..'))
del s, sf
@@ -642,18 +642,18 @@ class StrTest(unittest.TestCase, BaseStrTest):
s = ''.join([edge, '%s', edge])
del edge
s = s % '...'
- self.assertEquals(len(s), size * 2 + 3)
- self.assertEquals(s.count('.'), 3)
- self.assertEquals(s.count('-'), size * 2)
+ self.assertEqual(len(s), size * 2 + 3)
+ self.assertEqual(s.count('.'), 3)
+ self.assertEqual(s.count('-'), size * 2)
@bigmemtest(minsize=_2G + 10, memuse=character_size * 2)
def test_repr_small(self, size):
s = '-' * size
s = repr(s)
- self.assertEquals(len(s), size + 2)
- self.assertEquals(s[0], "'")
- self.assertEquals(s[-1], "'")
- self.assertEquals(s.count('-'), size)
+ self.assertEqual(len(s), size + 2)
+ self.assertEqual(s[0], "'")
+ self.assertEqual(s[-1], "'")
+ self.assertEqual(s.count('-'), size)
del s
# repr() will create a string four times as large as this 'binary
# string', but we don't want to allocate much more than twice
@@ -661,21 +661,21 @@ class StrTest(unittest.TestCase, BaseStrTest):
size = size // 5 * 2
s = '\x00' * size
s = repr(s)
- self.assertEquals(len(s), size * 4 + 2)
- self.assertEquals(s[0], "'")
- self.assertEquals(s[-1], "'")
- self.assertEquals(s.count('\\'), size)
- self.assertEquals(s.count('0'), size * 2)
+ self.assertEqual(len(s), size * 4 + 2)
+ self.assertEqual(s[0], "'")
+ self.assertEqual(s[-1], "'")
+ self.assertEqual(s.count('\\'), size)
+ self.assertEqual(s.count('0'), size * 2)
@bigmemtest(minsize=_2G + 10, memuse=character_size * 5)
def test_repr_large(self, size):
s = '\x00' * size
s = repr(s)
- self.assertEquals(len(s), size * 4 + 2)
- self.assertEquals(s[0], "'")
- self.assertEquals(s[-1], "'")
- self.assertEquals(s.count('\\'), size)
- self.assertEquals(s.count('0'), size * 2)
+ self.assertEqual(len(s), size * 4 + 2)
+ self.assertEqual(s[0], "'")
+ self.assertEqual(s[-1], "'")
+ self.assertEqual(s.count('\\'), size)
+ self.assertEqual(s.count('0'), size * 2)
@bigmemtest(minsize=2**32 / 5, memuse=character_size * 7)
def test_unicode_repr(self, size):
@@ -708,7 +708,7 @@ class BytesTest(unittest.TestCase, BaseStrTest):
@bigmemtest(minsize=_2G + 2, memuse=1 + character_size)
def test_decode(self, size):
s = self.from_latin1('.') * size
- self.assertEquals(len(s.decode('utf-8')), size)
+ self.assertEqual(len(s.decode('utf-8')), size)
class BytearrayTest(unittest.TestCase, BaseStrTest):
@@ -719,7 +719,7 @@ class BytearrayTest(unittest.TestCase, BaseStrTest):
@bigmemtest(minsize=_2G + 2, memuse=1 + character_size)
def test_decode(self, size):
s = self.from_latin1('.') * size
- self.assertEquals(len(s.decode('utf-8')), size)
+ self.assertEqual(len(s.decode('utf-8')), size)
test_hash = None
test_split_large = None
@@ -754,9 +754,9 @@ class TupleTest(unittest.TestCase):
# skipped, in verbose mode.)
def basic_concat_test(self, size):
t = ((),) * size
- self.assertEquals(len(t), size)
+ self.assertEqual(len(t), size)
t = t + t
- self.assertEquals(len(t), size * 2)
+ self.assertEqual(len(t), size * 2)
@bigmemtest(minsize=_2G // 2 + 2, memuse=24)
def test_concat_small(self, size):
@@ -769,7 +769,7 @@ class TupleTest(unittest.TestCase):
@bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5)
def test_contains(self, size):
t = (1, 2, 3, 4, 5) * size
- self.assertEquals(len(t), size * 5)
+ self.assertEqual(len(t), size * 5)
self.assertIn(5, t)
self.assertNotIn((1, 2, 3, 4, 5), t)
self.assertNotIn(0, t)
@@ -785,27 +785,27 @@ class TupleTest(unittest.TestCase):
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
t = (None,) * size
- self.assertEquals(len(t), size)
- self.assertEquals(t[-1], None)
- self.assertEquals(t[5], None)
- self.assertEquals(t[size - 1], None)
+ self.assertEqual(len(t), size)
+ self.assertEqual(t[-1], None)
+ self.assertEqual(t[5], None)
+ self.assertEqual(t[size - 1], None)
self.assertRaises(IndexError, operator.getitem, t, size)
- self.assertEquals(t[:5], (None,) * 5)
- self.assertEquals(t[-5:], (None,) * 5)
- self.assertEquals(t[20:25], (None,) * 5)
- self.assertEquals(t[-25:-20], (None,) * 5)
- self.assertEquals(t[size - 5:], (None,) * 5)
- self.assertEquals(t[size - 5:size], (None,) * 5)
- self.assertEquals(t[size - 6:size - 2], (None,) * 4)
- self.assertEquals(t[size:size], ())
- self.assertEquals(t[size:size+5], ())
+ self.assertEqual(t[:5], (None,) * 5)
+ self.assertEqual(t[-5:], (None,) * 5)
+ self.assertEqual(t[20:25], (None,) * 5)
+ self.assertEqual(t[-25:-20], (None,) * 5)
+ self.assertEqual(t[size - 5:], (None,) * 5)
+ self.assertEqual(t[size - 5:size], (None,) * 5)
+ self.assertEqual(t[size - 6:size - 2], (None,) * 4)
+ self.assertEqual(t[size:size], ())
+ self.assertEqual(t[size:size+5], ())
# Like test_concat, split in two.
def basic_test_repeat(self, size):
t = ('',) * size
- self.assertEquals(len(t), size)
+ self.assertEqual(len(t), size)
t = t * 2
- self.assertEquals(len(t), size * 2)
+ self.assertEqual(len(t), size * 2)
@bigmemtest(minsize=_2G // 2 + 2, memuse=24)
def test_repeat_small(self, size):
@@ -829,9 +829,9 @@ class TupleTest(unittest.TestCase):
else:
count = 0
for item in t:
- self.assertEquals(item, count)
+ self.assertEqual(item, count)
count += 1
- self.assertEquals(count, size)
+ self.assertEqual(count, size)
@precisionbigmemtest(size=_1G - 25, memuse=9)
def test_from_almost_2G_generator(self, size):
@@ -840,9 +840,9 @@ class TupleTest(unittest.TestCase):
t = tuple(range(size))
count = 0
for item in t:
- self.assertEquals(item, count)
+ self.assertEqual(item, count)
count += 1
- self.assertEquals(count, size)
+ self.assertEqual(count, size)
except MemoryError:
pass # acceptable, expected on 32-bit
@@ -851,10 +851,10 @@ class TupleTest(unittest.TestCase):
t = (0,) * size
s = repr(t)
# The repr of a tuple of 0's is exactly three times the tuple length.
- self.assertEquals(len(s), size * 3)
- self.assertEquals(s[:5], '(0, 0')
- self.assertEquals(s[-5:], '0, 0)')
- self.assertEquals(s.count('0'), size)
+ self.assertEqual(len(s), size * 3)
+ self.assertEqual(s[:5], '(0, 0')
+ self.assertEqual(s[-5:], '0, 0)')
+ self.assertEqual(s.count('0'), size)
@bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
@@ -890,9 +890,9 @@ class ListTest(unittest.TestCase):
# skipped, in verbose mode.)
def basic_test_concat(self, size):
l = [[]] * size
- self.assertEquals(len(l), size)
+ self.assertEqual(len(l), size)
l = l + l
- self.assertEquals(len(l), size * 2)
+ self.assertEqual(len(l), size * 2)
@bigmemtest(minsize=_2G // 2 + 2, memuse=24)
def test_concat_small(self, size):
@@ -905,7 +905,7 @@ class ListTest(unittest.TestCase):
def basic_test_inplace_concat(self, size):
l = [sys.stdout] * size
l += l
- self.assertEquals(len(l), size * 2)
+ self.assertEqual(len(l), size * 2)
self.assertTrue(l[0] is l[-1])
self.assertTrue(l[size - 1] is l[size + 1])
@@ -920,7 +920,7 @@ class ListTest(unittest.TestCase):
@bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5)
def test_contains(self, size):
l = [1, 2, 3, 4, 5] * size
- self.assertEquals(len(l), size * 5)
+ self.assertEqual(len(l), size * 5)
self.assertIn(5, l)
self.assertNotIn([1, 2, 3, 4, 5], l)
self.assertNotIn(0, l)
@@ -933,66 +933,66 @@ class ListTest(unittest.TestCase):
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
l = [None] * size
- self.assertEquals(len(l), size)
- self.assertEquals(l[-1], None)
- self.assertEquals(l[5], None)
- self.assertEquals(l[size - 1], None)
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-1], None)
+ self.assertEqual(l[5], None)
+ self.assertEqual(l[size - 1], None)
self.assertRaises(IndexError, operator.getitem, l, size)
- self.assertEquals(l[:5], [None] * 5)
- self.assertEquals(l[-5:], [None] * 5)
- self.assertEquals(l[20:25], [None] * 5)
- self.assertEquals(l[-25:-20], [None] * 5)
- self.assertEquals(l[size - 5:], [None] * 5)
- self.assertEquals(l[size - 5:size], [None] * 5)
- self.assertEquals(l[size - 6:size - 2], [None] * 4)
- self.assertEquals(l[size:size], [])
- self.assertEquals(l[size:size+5], [])
+ self.assertEqual(l[:5], [None] * 5)
+ self.assertEqual(l[-5:], [None] * 5)
+ self.assertEqual(l[20:25], [None] * 5)
+ self.assertEqual(l[-25:-20], [None] * 5)
+ self.assertEqual(l[size - 5:], [None] * 5)
+ self.assertEqual(l[size - 5:size], [None] * 5)
+ self.assertEqual(l[size - 6:size - 2], [None] * 4)
+ self.assertEqual(l[size:size], [])
+ self.assertEqual(l[size:size+5], [])
l[size - 2] = 5
- self.assertEquals(len(l), size)
- self.assertEquals(l[-3:], [None, 5, None])
- self.assertEquals(l.count(5), 1)
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-3:], [None, 5, None])
+ self.assertEqual(l.count(5), 1)
self.assertRaises(IndexError, operator.setitem, l, size, 6)
- self.assertEquals(len(l), size)
+ self.assertEqual(len(l), size)
l[size - 7:] = [1, 2, 3, 4, 5]
size -= 2
- self.assertEquals(len(l), size)
- self.assertEquals(l[-7:], [None, None, 1, 2, 3, 4, 5])
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-7:], [None, None, 1, 2, 3, 4, 5])
l[:7] = [1, 2, 3, 4, 5]
size -= 2
- self.assertEquals(len(l), size)
- self.assertEquals(l[:7], [1, 2, 3, 4, 5, None, None])
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[:7], [1, 2, 3, 4, 5, None, None])
del l[size - 1]
size -= 1
- self.assertEquals(len(l), size)
- self.assertEquals(l[-1], 4)
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-1], 4)
del l[-2:]
size -= 2
- self.assertEquals(len(l), size)
- self.assertEquals(l[-1], 2)
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-1], 2)
del l[0]
size -= 1
- self.assertEquals(len(l), size)
- self.assertEquals(l[0], 2)
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[0], 2)
del l[:2]
size -= 2
- self.assertEquals(len(l), size)
- self.assertEquals(l[0], 4)
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[0], 4)
# Like test_concat, split in two.
def basic_test_repeat(self, size):
l = [] * size
self.assertFalse(l)
l = [''] * size
- self.assertEquals(len(l), size)
+ self.assertEqual(len(l), size)
l = l * 2
- self.assertEquals(len(l), size * 2)
+ self.assertEqual(len(l), size * 2)
@bigmemtest(minsize=_2G // 2 + 2, memuse=24)
def test_repeat_small(self, size):
@@ -1005,13 +1005,13 @@ class ListTest(unittest.TestCase):
def basic_test_inplace_repeat(self, size):
l = ['']
l *= size
- self.assertEquals(len(l), size)
+ self.assertEqual(len(l), size)
self.assertTrue(l[0] is l[-1])
del l
l = [''] * size
l *= 2
- self.assertEquals(len(l), size * 2)
+ self.assertEqual(len(l), size * 2)
self.assertTrue(l[size - 1] is l[-1])
@bigmemtest(minsize=_2G // 2 + 2, memuse=16)
@@ -1026,10 +1026,10 @@ class ListTest(unittest.TestCase):
l = [0] * size
s = repr(l)
# The repr of a list of 0's is exactly three times the list length.
- self.assertEquals(len(s), size * 3)
- self.assertEquals(s[:5], '[0, 0')
- self.assertEquals(s[-5:], '0, 0]')
- self.assertEquals(s.count('0'), size)
+ self.assertEqual(len(s), size * 3)
+ self.assertEqual(s[:5], '[0, 0')
+ self.assertEqual(s[-5:], '0, 0]')
+ self.assertEqual(s.count('0'), size)
@bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
@@ -1045,20 +1045,20 @@ class ListTest(unittest.TestCase):
def test_append(self, size):
l = [object()] * size
l.append(object())
- self.assertEquals(len(l), size+1)
+ self.assertEqual(len(l), size+1)
self.assertTrue(l[-3] is l[-2])
self.assertFalse(l[-2] is l[-1])
@bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
def test_count(self, size):
l = [1, 2, 3, 4, 5] * size
- self.assertEquals(l.count(1), size)
- self.assertEquals(l.count("1"), 0)
+ self.assertEqual(l.count(1), size)
+ self.assertEqual(l.count("1"), 0)
def basic_test_extend(self, size):
l = [object] * size
l.extend(l)
- self.assertEquals(len(l), size * 2)
+ self.assertEqual(len(l), size * 2)
self.assertTrue(l[0] is l[-1])
self.assertTrue(l[size - 1] is l[size + 1])
@@ -1074,9 +1074,9 @@ class ListTest(unittest.TestCase):
def test_index(self, size):
l = [1, 2, 3, 4, 5] * size
size *= 5
- self.assertEquals(l.index(1), 0)
- self.assertEquals(l.index(5, size - 5), size - 1)
- self.assertEquals(l.index(5, size - 5, size), size - 1)
+ self.assertEqual(l.index(1), 0)
+ self.assertEqual(l.index(5, size - 5), size - 1)
+ self.assertEqual(l.index(5, size - 5, size), size - 1)
self.assertRaises(ValueError, l.index, 1, size - 4, size)
self.assertRaises(ValueError, l.index, 6)
@@ -1086,80 +1086,80 @@ class ListTest(unittest.TestCase):
l = [1.0] * size
l.insert(size - 1, "A")
size += 1
- self.assertEquals(len(l), size)
- self.assertEquals(l[-3:], [1.0, "A", 1.0])
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-3:], [1.0, "A", 1.0])
l.insert(size + 1, "B")
size += 1
- self.assertEquals(len(l), size)
- self.assertEquals(l[-3:], ["A", 1.0, "B"])
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-3:], ["A", 1.0, "B"])
l.insert(1, "C")
size += 1
- self.assertEquals(len(l), size)
- self.assertEquals(l[:3], [1.0, "C", 1.0])
- self.assertEquals(l[size - 3:], ["A", 1.0, "B"])
+ self.assertEqual(len(l), size)
+ 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)
def test_pop(self, size):
l = ["a", "b", "c", "d", "e"] * size
size *= 5
- self.assertEquals(len(l), size)
+ self.assertEqual(len(l), size)
item = l.pop()
size -= 1
- self.assertEquals(len(l), size)
- self.assertEquals(item, "e")
- self.assertEquals(l[-2:], ["c", "d"])
+ self.assertEqual(len(l), size)
+ self.assertEqual(item, "e")
+ self.assertEqual(l[-2:], ["c", "d"])
item = l.pop(0)
size -= 1
- self.assertEquals(len(l), size)
- self.assertEquals(item, "a")
- self.assertEquals(l[:2], ["b", "c"])
+ self.assertEqual(len(l), size)
+ self.assertEqual(item, "a")
+ self.assertEqual(l[:2], ["b", "c"])
item = l.pop(size - 2)
size -= 1
- self.assertEquals(len(l), size)
- self.assertEquals(item, "c")
- self.assertEquals(l[-2:], ["b", "d"])
+ self.assertEqual(len(l), size)
+ self.assertEqual(item, "c")
+ self.assertEqual(l[-2:], ["b", "d"])
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_remove(self, size):
l = [10] * size
- self.assertEquals(len(l), size)
+ self.assertEqual(len(l), size)
l.remove(10)
size -= 1
- self.assertEquals(len(l), size)
+ self.assertEqual(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)
- self.assertEquals(l[-2:], [10, 5])
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-2:], [10, 5])
l.remove(5)
size -= 1
- self.assertEquals(len(l), size)
- self.assertEquals(l[-2:], [10, 10])
+ self.assertEqual(len(l), size)
+ self.assertEqual(l[-2:], [10, 10])
@bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
def test_reverse(self, size):
l = [1, 2, 3, 4, 5] * size
l.reverse()
- self.assertEquals(len(l), size * 5)
- self.assertEquals(l[-5:], [5, 4, 3, 2, 1])
- self.assertEquals(l[:5], [5, 4, 3, 2, 1])
+ self.assertEqual(len(l), size * 5)
+ 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)
def test_sort(self, size):
l = [1, 2, 3, 4, 5] * size
l.sort()
- self.assertEquals(len(l), size * 5)
- self.assertEquals(l.count(1), size)
- self.assertEquals(l[:10], [1] * 10)
- self.assertEquals(l[-10:], [5] * 10)
+ self.assertEqual(len(l), size * 5)
+ self.assertEqual(l.count(1), size)
+ self.assertEqual(l[:10], [1] * 10)
+ self.assertEqual(l[-10:], [5] * 10)
def test_main():
support.run_unittest(StrTest, BytesTest, BytearrayTest,