Replace assertEquals with assertEqual

The method assertEquals has been deprecated since python 2.7.
http://docs.python.org/2/library/unittest.html#deprecated-aliases

Also in Python 3, a deprecated warning is raised when using assertEquals
therefore we should use assertEqual instead.

This is part of blueprint assertequal

Change-Id: I767b9817cb3718e93a41f345c8ccb41e1334e331
This commit is contained in:
Luong Anh Tuan 2016-11-21 15:40:07 +07:00
parent b439f20f9c
commit c46d4374ce
5 changed files with 16 additions and 16 deletions

View File

@ -134,7 +134,7 @@ class TestSwiftOnFile(Base):
file_name), 'r')
data_read_from_mountP = fhOnMountPoint.read()
md5_returned = hashlib.md5(data_read_from_mountP).hexdigest()
self.assertEquals(md5_returned, file_info['etag'])
self.assertEqual(md5_returned, file_info['etag'])
fhOnMountPoint.close()
def test_GET_on_file_created_over_mountpoint(self):

View File

@ -2872,7 +2872,7 @@ class TestObjectVersioning(Base):
container = self.env.container
versions_container = self.env.versions_container
cont_info = container.info()
self.assertEquals(cont_info['versions'], versions_container.name)
self.assertEqual(cont_info['versions'], versions_container.name)
obj_name = Utils.create_name()

View File

@ -67,13 +67,13 @@ class TestConstraintsMiddleware(unittest.TestCase):
path = '/V1.0/a/c/o'
resp = Request.blank(path, environ={'REQUEST_METHOD': 'GET'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def test_PUT_container(self):
path = '/V1.0/a/c'
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def test_PUT_object_with_double_slashes(self):
path = '/V1.0/a/c2//o'
@ -85,7 +85,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
"POLICIES", self.policies_mock)):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
self.assertTrue('Invalid object name' in resp.body)
self.assertTrue('cannot begin, end, or have' in resp.body)
@ -99,7 +99,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
"POLICIES", self.policies_mock)):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
self.assertTrue('Invalid object name' in resp.body)
self.assertTrue('can end with a slash only if it is a directory'
in resp.body)
@ -114,7 +114,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
"POLICIES", self.policies_mock)):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
self.assertTrue('Invalid object name' in resp.body)
self.assertTrue('cannot have . or ..' in resp.body)
@ -124,7 +124,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
resp = Request.blank(path, method='PUT',
headers={'X-Storage-Policy': 'swiftonfile'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
# test case where storage policy is not defined in header and
# container would be created in default policy, which happens to be
@ -137,7 +137,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
with patch("swiftonfile.swift.common.middleware.check_constraints."
"POLICIES", default_policies_mock):
resp = Request.blank(path, method='PUT').get_response(self.test_check)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
def test_PUT_object_with_long_names(self):
for i in (220,221):
@ -152,7 +152,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
"check_constraints.POLICIES", self.policies_mock)):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
longname = 'o' * 222
path = '/V1.0/a/c2/' + longname
@ -164,7 +164,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
"POLICIES", self.policies_mock)):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
self.assertTrue('too long' in resp.body)
def test_PUT_object_with_policy0(self):
@ -175,7 +175,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
self.container1_info_mock):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
longname = 'o' * 222
path = '/V1.0/a/c2/' + longname
@ -184,4 +184,4 @@ class TestConstraintsMiddleware(unittest.TestCase):
"get_container_info", self.container1_info_mock):
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)

View File

@ -604,7 +604,7 @@ class TestDiskFile(unittest.TestCase):
the_dir = os.path.join(the_cont, "dir")
os.makedirs(the_dir)
gdf = self._get_diskfile("vol0", "p57", "ufo47", "bar", "dir")
self.assertEquals(gdf._metadata, None)
self.assertEqual(gdf._metadata, None)
init_md = {
'X-Type': 'Object',
'Content-Length': 0,

View File

@ -54,11 +54,11 @@ class TestObjectController(unittest.TestCase):
environ={'REQUEST_METHOD': 'REPLICATE'},
headers={})
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 501) # HTTPNotImplemented
self.assertEqual(resp.status_int, 501) # HTTPNotImplemented
def test_REPLICATION(self):
req = Request.blank('/sda1/p/suff',
environ={'REQUEST_METHOD': 'REPLICATION'},
headers={})
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 501) # HTTPNotImplemented
self.assertEqual(resp.status_int, 501) # HTTPNotImplemented