summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryview.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-11-20 19:04:17 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-11-20 19:04:17 (GMT)
commitb3aedd48621ed9d33b5f42f946b256bce4a50673 (patch)
tree2297c8ebce1b09621e1d98096c1603896d9a0f0c /Lib/test/test_memoryview.py
parentb8bc439b2093add9b313bcca2cc507a2d0e87764 (diff)
downloadcpython-b3aedd48621ed9d33b5f42f946b256bce4a50673.zip
cpython-b3aedd48621ed9d33b5f42f946b256bce4a50673.tar.gz
cpython-b3aedd48621ed9d33b5f42f946b256bce4a50673.tar.bz2
#9424: Replace deprecated assert* methods in the Python test suite.
Diffstat (limited to 'Lib/test/test_memoryview.py')
-rw-r--r--Lib/test/test_memoryview.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index d56d64f..7bccf8b 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -27,11 +27,11 @@ class AbstractMemoryTests:
b = tp(self._source)
oldrefcount = sys.getrefcount(b)
m = self._view(b)
- self.assertEquals(m[0], item(b"a"))
+ self.assertEqual(m[0], item(b"a"))
self.assertIsInstance(m[0], bytes)
- self.assertEquals(m[5], item(b"f"))
- self.assertEquals(m[-1], item(b"f"))
- self.assertEquals(m[-6], item(b"a"))
+ self.assertEqual(m[5], item(b"f"))
+ self.assertEqual(m[-1], item(b"f"))
+ self.assertEqual(m[-6], item(b"a"))
# Bounds checking
self.assertRaises(IndexError, lambda: m[6])
self.assertRaises(IndexError, lambda: m[-7])
@@ -42,7 +42,7 @@ class AbstractMemoryTests:
self.assertRaises(TypeError, lambda: m[0.0])
self.assertRaises(TypeError, lambda: m["a"])
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ self.assertEqual(sys.getrefcount(b), oldrefcount)
def test_getitem(self):
for tp in self._types:
@@ -66,7 +66,7 @@ class AbstractMemoryTests:
self.assertRaises(TypeError, setitem, 65)
self.assertRaises(TypeError, setitem, memoryview(b"a"))
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ self.assertEqual(sys.getrefcount(b), oldrefcount)
def test_setitem_writable(self):
if not self.rw_type:
@@ -109,7 +109,7 @@ class AbstractMemoryTests:
self.assertRaises(ValueError, setitem, slice(0,2), b"a")
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ self.assertEqual(sys.getrefcount(b), oldrefcount)
def test_delitem(self):
for tp in self._types:
@@ -127,14 +127,14 @@ class AbstractMemoryTests:
# This calls self.getitem_type() on each separate byte of b"abcdef"
expected = b"".join(
self.getitem_type(bytes([c])) for c in b"abcdef")
- self.assertEquals(b, expected)
+ self.assertEqual(b, expected)
self.assertIsInstance(b, bytes)
def test_tolist(self):
for tp in self._types:
m = self._view(tp(self._source))
l = m.tolist()
- self.assertEquals(l, list(b"abcdef"))
+ self.assertEqual(l, list(b"abcdef"))
def test_compare(self):
# memoryviews can compare for equality with other objects
@@ -168,26 +168,26 @@ class AbstractMemoryTests:
def check_attributes_with_type(self, tp):
m = self._view(tp(self._source))
- self.assertEquals(m.format, self.format)
- self.assertEquals(m.itemsize, self.itemsize)
- self.assertEquals(m.ndim, 1)
- self.assertEquals(m.shape, (6,))
- self.assertEquals(len(m), 6)
- self.assertEquals(m.strides, (self.itemsize,))
- self.assertEquals(m.suboffsets, None)
+ self.assertEqual(m.format, self.format)
+ self.assertEqual(m.itemsize, self.itemsize)
+ self.assertEqual(m.ndim, 1)
+ self.assertEqual(m.shape, (6,))
+ self.assertEqual(len(m), 6)
+ self.assertEqual(m.strides, (self.itemsize,))
+ self.assertEqual(m.suboffsets, None)
return m
def test_attributes_readonly(self):
if not self.ro_type:
return
m = self.check_attributes_with_type(self.ro_type)
- self.assertEquals(m.readonly, True)
+ self.assertEqual(m.readonly, True)
def test_attributes_writable(self):
if not self.rw_type:
return
m = self.check_attributes_with_type(self.rw_type)
- self.assertEquals(m.readonly, False)
+ self.assertEqual(m.readonly, False)
def test_getbuffer(self):
# Test PyObject_GetBuffer() on a memoryview object.
@@ -198,9 +198,9 @@ class AbstractMemoryTests:
oldviewrefcount = sys.getrefcount(m)
s = str(m, "utf-8")
self._check_contents(tp, b, s.encode("utf-8"))
- self.assertEquals(sys.getrefcount(m), oldviewrefcount)
+ self.assertEqual(sys.getrefcount(m), oldviewrefcount)
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ self.assertEqual(sys.getrefcount(b), oldrefcount)
def test_gc(self):
for tp in self._types:
@@ -307,7 +307,7 @@ class BaseMemoryviewTests:
return memoryview(obj)
def _check_contents(self, tp, obj, contents):
- self.assertEquals(obj, tp(contents))
+ self.assertEqual(obj, tp(contents))
class BaseMemorySliceTests:
source_bytes = b"XabcdefY"
@@ -317,14 +317,14 @@ class BaseMemorySliceTests:
return m[1:7]
def _check_contents(self, tp, obj, contents):
- self.assertEquals(obj[1:7], tp(contents))
+ self.assertEqual(obj[1:7], tp(contents))
def test_refs(self):
for tp in self._types:
m = memoryview(tp(self._source))
oldrefcount = sys.getrefcount(m)
m[1:2]
- self.assertEquals(sys.getrefcount(m), oldrefcount)
+ self.assertEqual(sys.getrefcount(m), oldrefcount)
class BaseMemorySliceSliceTests:
source_bytes = b"XabcdefY"
@@ -334,7 +334,7 @@ class BaseMemorySliceSliceTests:
return m[:7][1:]
def _check_contents(self, tp, obj, contents):
- self.assertEquals(obj[1:7], tp(contents))
+ self.assertEqual(obj[1:7], tp(contents))
# Concrete test classes
@@ -361,7 +361,7 @@ class ArrayMemoryviewTest(unittest.TestCase,
m = memoryview(a)
new_a = array.array('i', range(9, -1, -1))
m[:] = new_a
- self.assertEquals(a, new_a)
+ self.assertEqual(a, new_a)
class BytesMemorySliceTest(unittest.TestCase,