change assert(Not)Equals to assert(Not)Equal

According to http://docs.python.org/2/library/unittest.html
assert(Not)Equals is a deprecated alias of assert(Not)Equal.

Change-Id: I75845cb9b71bcbaec76e12492b38260e09a2df13
Closes-Bug: #1329757
This commit is contained in:
zhangyangyang 2017-09-14 14:48:50 +08:00
parent 73672a47a4
commit 48a4c8b493
5 changed files with 23 additions and 22 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

@ -57,7 +57,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
self.policies_mock = Mock()
self.sof_policy_mock = Mock()
self.sof_policy_mock.name = 'swiftonfile'
attrs = {'get_by_index.return_value': self.sof_policy_mock }
attrs = {'get_by_index.return_value': self.sof_policy_mock}
self.policies_mock.configure_mock(**attrs)
self.test_check = check_constraints.filter_factory(
@ -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
@ -132,15 +132,15 @@ class TestConstraintsMiddleware(unittest.TestCase):
default_policies_mock = Mock()
sof_policy_mock = Mock()
sof_policy_mock.name = 'swiftonfile'
attrs = {'default.return_value': self.sof_policy_mock }
attrs = {'default.return_value': self.sof_policy_mock}
default_policies_mock.configure_mock(**attrs)
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):
for i in (220, 221):
longname = 'o' * i
path = '/V1.0/a/c2/' + longname
@ -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

@ -100,6 +100,7 @@ class MockRenamerCalled(Exception):
def _mock_renamer(a, b):
raise MockRenamerCalled()
class TestDiskFileWriter(unittest.TestCase):
""" Tests for swiftonfile.swift.obj.diskfile.DiskFileWriter """
@ -119,6 +120,7 @@ class TestDiskFileWriter(unittest.TestCase):
self.assertEqual(None, dw._fd)
self.assertEqual(1, mock_close.call_count)
class TestDiskFile(unittest.TestCase):
""" Tests for swiftonfile.swift.obj.diskfile """
@ -561,7 +563,7 @@ class TestDiskFile(unittest.TestCase):
md = {'Content-Type': 'application/octet-stream', 'a': 'b'}
gdf.write_metadata(md.copy())
self.assertTrue(_metadata[_mapit(the_file)]['a'], 'b')
newmd = {'X-Object-Meta-test':'1234'}
newmd = {'X-Object-Meta-test': '1234'}
gdf.write_metadata(newmd.copy())
on_disk_md = _metadata[_mapit(the_file)]
self.assertTrue(on_disk_md['Content-Length'], 4)
@ -604,7 +606,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,
@ -632,7 +634,6 @@ class TestDiskFile(unittest.TestCase):
DIR_OBJECT)
self.assertFalse('X-Object-Meta-test' in _metadata[_mapit(the_dir)])
def test_write_metadata_w_meta_file(self):
the_path = os.path.join(self.td, "vol0", "ufo47", "bar")
the_file = os.path.join(the_path, "z")

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