diff --git a/test/functional/tests.py b/test/functional/tests.py index dd92827a4f..8f7e2e8d17 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -2863,7 +2863,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() diff --git a/test/probe/test_account_failures.py b/test/probe/test_account_failures.py index 4d6b1496b9..9f7adc0a34 100755 --- a/test/probe/test_account_failures.py +++ b/test/probe/test_account_failures.py @@ -187,7 +187,7 @@ class TestAccountFailures(ReplProbeTest): found2 = True self.assertEqual(container['count'], 2) self.assertEqual(container['bytes'], 9) - self.assertEquals(container['bytes'], 9) + self.assertEqual(container['bytes'], 9) self.assertFalse(found1) self.assertTrue(found2) diff --git a/test/unit/common/middleware/test_account_quotas.py b/test/unit/common/middleware/test_account_quotas.py index e8e461fd53..345e178cd1 100644 --- a/test/unit/common/middleware/test_account_quotas.py +++ b/test/unit/common/middleware/test_account_quotas.py @@ -97,7 +97,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}) res = req.get_response(app) # Response code of 200 because authentication itself is not done here - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_no_quotas(self): headers = [('x-account-bytes-used', '1000'), ] @@ -107,7 +107,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_obj_request_ignores_attempt_to_set_quotas(self): # If you try to set X-Account-Meta-* on an object, it's ignored, so @@ -121,7 +121,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_container_request_ignores_attempt_to_set_quotas(self): # As with an object, if you try to set X-Account-Meta-* on a @@ -134,7 +134,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_bogus_quota_is_ignored(self): # This can happen if the metadata was set by a user prior to the @@ -147,7 +147,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_exceed_bytes_quota(self): headers = [('x-account-bytes-used', '1000'), @@ -158,8 +158,8 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_quota_not_authorized(self): headers = [('x-account-bytes-used', '1000'), @@ -171,7 +171,7 @@ class TestAccountQuota(unittest.TestCase): headers={'x-auth-token': 'bad-secret'}, environ={'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 403) + self.assertEqual(res.status_int, 403) def test_exceed_quota_authorized(self): headers = [('x-account-bytes-used', '1000'), @@ -183,7 +183,7 @@ class TestAccountQuota(unittest.TestCase): headers={'x-auth-token': 'secret'}, environ={'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) + self.assertEqual(res.status_int, 413) def test_under_quota_not_authorized(self): headers = [('x-account-bytes-used', '0'), @@ -195,7 +195,7 @@ class TestAccountQuota(unittest.TestCase): headers={'x-auth-token': 'bad-secret'}, environ={'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 403) + self.assertEqual(res.status_int, 403) def test_under_quota_authorized(self): headers = [('x-account-bytes-used', '0'), @@ -207,7 +207,7 @@ class TestAccountQuota(unittest.TestCase): headers={'x-auth-token': 'secret'}, environ={'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_over_quota_container_create_still_works(self): headers = [('x-account-bytes-used', '1001'), @@ -219,7 +219,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_CONTAINER_META_BERT': 'ernie', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_over_quota_container_post_still_works(self): headers = [('x-account-bytes-used', '1001'), @@ -231,7 +231,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_CONTAINER_META_BERT': 'ernie', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_over_quota_obj_post_still_works(self): headers = [('x-account-bytes-used', '1001'), @@ -243,7 +243,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_OBJECT_META_BERT': 'ernie', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_exceed_bytes_quota_copy_from(self): headers = [('x-account-bytes-used', '500'), @@ -256,8 +256,8 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_bytes_quota_copy_verb(self): headers = [('x-account-bytes-used', '500'), @@ -270,8 +270,8 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_not_exceed_bytes_quota_copy_from(self): headers = [('x-account-bytes-used', '0'), @@ -284,7 +284,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_exceed_bytes_quota_copy_verb(self): headers = [('x-account-bytes-used', '0'), @@ -297,7 +297,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_quota_copy_from_no_src(self): headers = [('x-account-bytes-used', '0'), @@ -309,7 +309,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o3'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_quota_copy_from_bad_src(self): headers = [('x-account-bytes-used', '0'), @@ -321,7 +321,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': 'bad_path'}) res = req.get_response(app) - self.assertEquals(res.status_int, 412) + self.assertEqual(res.status_int, 412) def test_exceed_bytes_quota_reseller(self): headers = [('x-account-bytes-used', '1000'), @@ -333,7 +333,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache, 'reseller_request': True}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_exceed_bytes_quota_reseller_copy_from(self): headers = [('x-account-bytes-used', '500'), @@ -347,7 +347,7 @@ class TestAccountQuota(unittest.TestCase): 'reseller_request': True}, headers={'x-copy-from': 'c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_exceed_bytes_quota_reseller_copy_verb(self): headers = [('x-account-bytes-used', '500'), @@ -361,7 +361,7 @@ class TestAccountQuota(unittest.TestCase): 'reseller_request': True}, headers={'Destination': 'c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_bad_application_quota(self): headers = [] @@ -371,7 +371,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 404) + self.assertEqual(res.status_int, 404) def test_no_info_quota(self): headers = [] @@ -381,7 +381,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_exceed_bytes_quota(self): headers = [('x-account-bytes-used', '1000'), @@ -392,7 +392,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_invalid_quotas(self): headers = [('x-account-bytes-used', '0'), ] @@ -404,7 +404,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_ACCOUNT_META_QUOTA_BYTES': 'abc', 'reseller_request': True}) res = req.get_response(app) - self.assertEquals(res.status_int, 400) + self.assertEqual(res.status_int, 400) def test_valid_quotas_admin(self): headers = [('x-account-bytes-used', '0'), ] @@ -415,7 +415,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache, 'HTTP_X_ACCOUNT_META_QUOTA_BYTES': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 403) + self.assertEqual(res.status_int, 403) def test_valid_quotas_reseller(self): headers = [('x-account-bytes-used', '0'), ] @@ -427,7 +427,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_ACCOUNT_META_QUOTA_BYTES': '100', 'reseller_request': True}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_delete_quotas(self): headers = [('x-account-bytes-used', '0'), ] @@ -438,7 +438,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache, 'HTTP_X_ACCOUNT_META_QUOTA_BYTES': ''}) res = req.get_response(app) - self.assertEquals(res.status_int, 403) + self.assertEqual(res.status_int, 403) def test_delete_quotas_with_remove_header(self): headers = [('x-account-bytes-used', '0'), ] @@ -449,7 +449,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache, 'HTTP_X_REMOVE_ACCOUNT_META_QUOTA_BYTES': 'True'}) res = req.get_response(app) - self.assertEquals(res.status_int, 403) + self.assertEqual(res.status_int, 403) def test_delete_quotas_reseller(self): headers = [('x-account-bytes-used', '0'), ] @@ -459,7 +459,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_ACCOUNT_META_QUOTA_BYTES': '', 'reseller_request': True}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_delete_quotas_with_remove_header_reseller(self): headers = [('x-account-bytes-used', '0'), ] @@ -471,7 +471,7 @@ class TestAccountQuota(unittest.TestCase): 'HTTP_X_REMOVE_ACCOUNT_META_QUOTA_BYTES': 'True', 'reseller_request': True}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_invalid_request_exception(self): headers = [('x-account-bytes-used', '1000'), ] @@ -482,7 +482,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}) res = req.get_response(app) # Response code of 200 because authentication itself is not done here - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) if __name__ == '__main__': diff --git a/test/unit/common/middleware/test_acl.py b/test/unit/common/middleware/test_acl.py index aa100bc4db..614056c0f2 100644 --- a/test/unit/common/middleware/test_acl.py +++ b/test/unit/common/middleware/test_acl.py @@ -22,36 +22,36 @@ class TestACL(unittest.TestCase): def test_clean_acl(self): value = acl.clean_acl('header', '.r:*') - self.assertEquals(value, '.r:*') + self.assertEqual(value, '.r:*') value = acl.clean_acl('header', '.r:specific.host') - self.assertEquals(value, '.r:specific.host') + self.assertEqual(value, '.r:specific.host') value = acl.clean_acl('header', '.r:.ending.with') - self.assertEquals(value, '.r:.ending.with') + self.assertEqual(value, '.r:.ending.with') value = acl.clean_acl('header', '.r:*.ending.with') - self.assertEquals(value, '.r:.ending.with') + self.assertEqual(value, '.r:.ending.with') value = acl.clean_acl('header', '.r:-*.ending.with') - self.assertEquals(value, '.r:-.ending.with') + self.assertEqual(value, '.r:-.ending.with') value = acl.clean_acl('header', '.r:one,.r:two') - self.assertEquals(value, '.r:one,.r:two') + self.assertEqual(value, '.r:one,.r:two') value = acl.clean_acl('header', '.r:*,.r:-specific.host') - self.assertEquals(value, '.r:*,.r:-specific.host') + self.assertEqual(value, '.r:*,.r:-specific.host') value = acl.clean_acl('header', '.r:*,.r:-.ending.with') - self.assertEquals(value, '.r:*,.r:-.ending.with') + self.assertEqual(value, '.r:*,.r:-.ending.with') value = acl.clean_acl('header', '.r:one,.r:-two') - self.assertEquals(value, '.r:one,.r:-two') + self.assertEqual(value, '.r:one,.r:-two') value = acl.clean_acl('header', '.r:one,.r:-two,account,account:user') - self.assertEquals(value, '.r:one,.r:-two,account,account:user') + self.assertEqual(value, '.r:one,.r:-two,account,account:user') value = acl.clean_acl('header', 'TEST_account') - self.assertEquals(value, 'TEST_account') + self.assertEqual(value, 'TEST_account') value = acl.clean_acl('header', '.ref:*') - self.assertEquals(value, '.r:*') + self.assertEqual(value, '.r:*') value = acl.clean_acl('header', '.referer:*') - self.assertEquals(value, '.r:*') + self.assertEqual(value, '.r:*') value = acl.clean_acl('header', '.referrer:*') - self.assertEquals(value, '.r:*') + self.assertEqual(value, '.r:*') value = acl.clean_acl('header', ' .r : one , ,, .r:two , .r : - three ') - self.assertEquals(value, '.r:one,.r:two,.r:-three') + self.assertEqual(value, '.r:one,.r:two,.r:-three') self.assertRaises(ValueError, acl.clean_acl, 'header', '.unknown:test') self.assertRaises(ValueError, acl.clean_acl, 'header', '.r:') self.assertRaises(ValueError, acl.clean_acl, 'header', '.r:*.') @@ -67,16 +67,16 @@ class TestACL(unittest.TestCase): self.assertRaises(ValueError, acl.clean_acl, 'write-header', '.r:r') def test_parse_acl(self): - self.assertEquals(acl.parse_acl(None), ([], [])) - self.assertEquals(acl.parse_acl(''), ([], [])) - self.assertEquals(acl.parse_acl('.r:ref1'), (['ref1'], [])) - self.assertEquals(acl.parse_acl('.r:-ref1'), (['-ref1'], [])) - self.assertEquals(acl.parse_acl('account:user'), - ([], ['account:user'])) - self.assertEquals(acl.parse_acl('account'), ([], ['account'])) - self.assertEquals(acl.parse_acl('acc1,acc2:usr2,.r:ref3,.r:-ref4'), - (['ref3', '-ref4'], ['acc1', 'acc2:usr2'])) - self.assertEquals(acl.parse_acl( + self.assertEqual(acl.parse_acl(None), ([], [])) + self.assertEqual(acl.parse_acl(''), ([], [])) + self.assertEqual(acl.parse_acl('.r:ref1'), (['ref1'], [])) + self.assertEqual(acl.parse_acl('.r:-ref1'), (['-ref1'], [])) + self.assertEqual(acl.parse_acl('account:user'), + ([], ['account:user'])) + self.assertEqual(acl.parse_acl('account'), ([], ['account'])) + self.assertEqual(acl.parse_acl('acc1,acc2:usr2,.r:ref3,.r:-ref4'), + (['ref3', '-ref4'], ['acc1', 'acc2:usr2'])) + self.assertEqual(acl.parse_acl( 'acc1,acc2:usr2,.r:ref3,acc3,acc4:usr4,.r:ref5,.r:-ref6'), (['ref3', 'ref5', '-ref6'], ['acc1', 'acc2:usr2', 'acc3', 'acc4:usr4'])) @@ -105,8 +105,8 @@ class TestACL(unittest.TestCase): for hdrs_in, expected in tests: result = acl.parse_acl(version=2, data=hdrs_in.get('hdr')) - self.assertEquals(expected, result, - '%r: %r != %r' % (hdrs_in, result, expected)) + self.assertEqual(expected, result, + '%r: %r != %r' % (hdrs_in, result, expected)) def test_format_v1_acl(self): tests = [ @@ -120,8 +120,8 @@ class TestACL(unittest.TestCase): for (groups, refs), expected in tests: result = acl.format_acl( version=1, groups=groups, referrers=refs, header_name='hdr') - self.assertEquals(expected, result, 'groups=%r, refs=%r: %r != %r' - % (groups, refs, result, expected)) + self.assertEqual(expected, result, 'groups=%r, refs=%r: %r != %r' + % (groups, refs, result, expected)) def test_format_v2_acl(self): tests = [ @@ -133,8 +133,8 @@ class TestACL(unittest.TestCase): for data, expected in tests: result = acl.format_acl(version=2, acl_dict=data) - self.assertEquals(expected, result, - 'data=%r: %r *!=* %r' % (data, result, expected)) + self.assertEqual(expected, result, + 'data=%r: %r *!=* %r' % (data, result, expected)) def test_acls_from_account_info(self): test_data = [ diff --git a/test/unit/common/middleware/test_bulk.py b/test/unit/common/middleware/test_bulk.py index a3982887c9..a024a94ff6 100644 --- a/test/unit/common/middleware/test_bulk.py +++ b/test/unit/common/middleware/test_bulk.py @@ -248,15 +248,15 @@ class TestUntar(unittest.TestCase): def test_create_container_for_path(self): req = Request.blank('/') - self.assertEquals( + self.assertEqual( self.bulk.create_container(req, '/create_cont/acc/cont'), True) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) self.assertRaises( bulk.CreateContainerError, self.bulk.create_container, req, '/create_cont_fail/acc/cont') - self.assertEquals(self.app.calls, 3) + self.assertEqual(self.app.calls, 3) def test_extract_tar_works(self): # On systems where $TMPDIR is long (like OS X), we need to do this @@ -289,7 +289,7 @@ class TestUntar(unittest.TestCase): req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, compress_format) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Files Created'], 6) + self.assertEqual(resp_data['Number Files Created'], 6) # test out xml req = Request.blank('/tar_works/acc/cont/') @@ -342,7 +342,7 @@ class TestUntar(unittest.TestCase): req.environ['wsgi.input'] = open( os.path.join(self.testdir, 'tar_works.tar.gz')) self.bulk(req.environ, fake_start_response) - self.assertEquals(self.app.calls, 1) + self.assertEqual(self.app.calls, 1) self.app.calls = 0 req.environ['wsgi.input'] = open( @@ -351,7 +351,7 @@ class TestUntar(unittest.TestCase): req.method = 'PUT' app_iter = self.bulk(req.environ, fake_start_response) list(app_iter) # iter over resp - self.assertEquals(self.app.calls, 7) + self.assertEqual(self.app.calls, 7) self.app.calls = 0 req = Request.blank('/tar_works/acc/cont/?extract-archive=bad') @@ -360,7 +360,7 @@ class TestUntar(unittest.TestCase): req.environ['wsgi.input'] = open( os.path.join(self.testdir, 'tar_works.tar.gz')) t = self.bulk(req.environ, fake_start_response) - self.assertEquals(t[0], "Unsupported archive format") + self.assertEqual(t[0], "Unsupported archive format") tar = tarfile.open(name=os.path.join(self.testdir, 'tar_works.tar'), @@ -375,7 +375,7 @@ class TestUntar(unittest.TestCase): os.path.join(self.testdir, 'tar_works.tar')) app_iter = self.bulk(req.environ, fake_start_response) list(app_iter) # iter over resp - self.assertEquals(self.app.calls, 7) + self.assertEqual(self.app.calls, 7) def test_bad_container(self): req = Request.blank('/invalid/', body='') @@ -424,7 +424,7 @@ class TestUntar(unittest.TestCase): req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Files Created'], 4) + self.assertEqual(resp_data['Number Files Created'], 4) def test_extract_tar_fail_cont_401(self): self.build_tar() @@ -434,10 +434,10 @@ class TestUntar(unittest.TestCase): 'tar_fails.tar')) req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') - self.assertEquals(self.app.calls, 1) + self.assertEqual(self.app.calls, 1) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '401 Unauthorized') - self.assertEquals(resp_data['Errors'], []) + self.assertEqual(resp_data['Response Status'], '401 Unauthorized') + self.assertEqual(resp_data['Errors'], []) def test_extract_tar_fail_obj_401(self): self.build_tar() @@ -447,10 +447,10 @@ class TestUntar(unittest.TestCase): 'tar_fails.tar')) req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '401 Unauthorized') - self.assertEquals( + self.assertEqual(resp_data['Response Status'], '401 Unauthorized') + self.assertEqual( resp_data['Errors'], [['cont/base_fails1/sub_dir1/sub1_file1', '401 Unauthorized']]) @@ -462,10 +462,10 @@ class TestUntar(unittest.TestCase): 'tar_fails.tar')) req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') - self.assertEquals(self.app.calls, 6) + self.assertEqual(self.app.calls, 6) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Files Created'], 4) - self.assertEquals( + self.assertEqual(resp_data['Number Files Created'], 4) + self.assertEqual( resp_data['Errors'], [['cont/base_fails1/' + ('f' * 101), '400 Bad Request']]) @@ -477,10 +477,10 @@ class TestUntar(unittest.TestCase): 'tar_fails.tar')) req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, 'gz') - self.assertEquals(self.app.calls, 0) + self.assertEqual(self.app.calls, 0) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals( + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual( resp_data['Response Body'].lower(), 'invalid tar file: not a gzip file') @@ -494,10 +494,10 @@ class TestUntar(unittest.TestCase): 'tar_fails.tar')) req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') - self.assertEquals(self.app.calls, 5) + self.assertEqual(self.app.calls, 5) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Files Created'], 3) - self.assertEquals( + self.assertEqual(resp_data['Number Files Created'], 3) + self.assertEqual( resp_data['Errors'], [['cont/base_fails1/' + ('f' * 101), '400 Bad Request']]) @@ -519,7 +519,7 @@ class TestUntar(unittest.TestCase): req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') resp_data = utils.json.loads(resp_body) - self.assertEquals( + self.assertEqual( resp_data['Errors'], [['cont' + self.testdir + '/test/sub_dir1/sub1_file1', '413 Request Entity Too Large']]) @@ -537,10 +537,10 @@ class TestUntar(unittest.TestCase): headers={'Accept': 'application/json'}) req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') - self.assertEquals(self.app.calls, 5) + self.assertEqual(self.app.calls, 5) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals( + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual( resp_data['Response Body'], 'More than 1 containers to create from tar.') @@ -557,8 +557,8 @@ class TestUntar(unittest.TestCase): req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') resp_data = utils.json.loads(resp_body) - self.assertEquals(self.app.calls, 5) - self.assertEquals(len(resp_data['Errors']), 5) + self.assertEqual(self.app.calls, 5) + self.assertEqual(len(resp_data['Errors']), 5) def test_extract_tar_fail_create_cont_value_err(self): self.build_tar() @@ -574,9 +574,9 @@ class TestUntar(unittest.TestCase): with patch.object(self.bulk, 'create_container', bad_create): resp_body = self.handle_extract_and_iter(req, '') resp_data = utils.json.loads(resp_body) - self.assertEquals(self.app.calls, 0) - self.assertEquals(len(resp_data['Errors']), 5) - self.assertEquals( + self.assertEqual(self.app.calls, 0) + self.assertEqual(len(resp_data['Errors']), 5) + self.assertEqual( resp_data['Errors'][0], ['cont/base_fails1/sub_dir1/sub1_file1', '400 Bad Request']) @@ -592,10 +592,10 @@ class TestUntar(unittest.TestCase): req.headers['transfer-encoding'] = 'chunked' resp_body = self.handle_extract_and_iter(req, '') resp_data = utils.json.loads(resp_body) - self.assertEquals(self.app.calls, 4) - self.assertEquals(resp_data['Number Files Created'], 2) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals( + self.assertEqual(self.app.calls, 4) + self.assertEqual(resp_data['Number Files Created'], 2) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual( resp_data['Errors'], [['sub_dir2/sub2%DEfile1', '412 Precondition Failed'], ['sub_%DEdir3/sub4_dir1/sub4_file1', '412 Precondition Failed']]) @@ -636,42 +636,42 @@ class TestDelete(unittest.TestCase): resp_body = ''.join(self.bulk.handle_delete_iter( req, objs_to_delete=objs_to_delete, out_content_type='application/json')) - self.assertEquals( + self.assertEqual( self.app.delete_paths, ['/delete_works/AUTH_Acc/c/file_a', '/delete_works/AUTH_Acc/c/file_d']) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Number Deleted'], 2) - self.assertEquals(resp_data['Number Not Found'], 1) - self.assertEquals(resp_data['Errors'], - [['/c/file_c', 'unauthorized']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Number Deleted'], 2) + self.assertEqual(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Errors'], + [['/c/file_c', 'unauthorized']]) def test_bulk_delete_works_with_POST_verb(self): req = Request.blank('/delete_works/AUTH_Acc', body='/c/f\n/c/f404', headers={'Accept': 'application/json'}) req.method = 'POST' resp_body = self.handle_delete_and_iter(req) - self.assertEquals( + self.assertEqual( self.app.delete_paths, ['/delete_works/AUTH_Acc/c/f', '/delete_works/AUTH_Acc/c/f404']) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 1) - self.assertEquals(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Number Deleted'], 1) + self.assertEqual(resp_data['Number Not Found'], 1) def test_bulk_delete_works_with_DELETE_verb(self): req = Request.blank('/delete_works/AUTH_Acc', body='/c/f\n/c/f404', headers={'Accept': 'application/json'}) req.method = 'DELETE' resp_body = self.handle_delete_and_iter(req) - self.assertEquals( + self.assertEqual( self.app.delete_paths, ['/delete_works/AUTH_Acc/c/f', '/delete_works/AUTH_Acc/c/f404']) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 1) - self.assertEquals(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Number Deleted'], 1) + self.assertEqual(resp_data['Number Not Found'], 1) def test_bulk_delete_bad_content_type(self): req = Request.blank('/delete_works/AUTH_Acc', @@ -684,11 +684,11 @@ class TestDelete(unittest.TestCase): req.environ['wsgi.input'] = BytesIO(b'/c/f\n/c/f404') resp_body = self.handle_delete_and_iter(req) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '406 Not Acceptable') + self.assertEqual(resp_data['Response Status'], '406 Not Acceptable') def test_bulk_delete_call_and_content_type(self): def fake_start_response(*args, **kwargs): - self.assertEquals(args[1][0], ('Content-Type', 'application/json')) + self.assertEqual(args[1][0], ('Content-Type', 'application/json')) req = Request.blank('/delete_works/AUTH_Acc?bulk-delete') req.method = 'POST' @@ -696,23 +696,23 @@ class TestDelete(unittest.TestCase): req.headers['Accept'] = 'application/json' req.environ['wsgi.input'] = BytesIO(b'/c/f%20') list(self.bulk(req.environ, fake_start_response)) # iterate over resp - self.assertEquals( + self.assertEqual( self.app.delete_paths, ['/delete_works/AUTH_Acc/c/f ']) - self.assertEquals(self.app.calls, 1) + self.assertEqual(self.app.calls, 1) def test_bulk_delete_get_objs(self): req = Request.blank('/delete_works/AUTH_Acc', body='1%20\r\n2\r\n') req.method = 'POST' with patch.object(self.bulk, 'max_deletes_per_request', 2): results = self.bulk.get_objs_to_delete(req) - self.assertEquals(results, [{'name': '1 '}, {'name': '2'}]) + self.assertEqual(results, [{'name': '1 '}, {'name': '2'}]) with patch.object(self.bulk, 'max_path_length', 2): results = [] req.environ['wsgi.input'] = BytesIO(b'1\n2\n3') results = self.bulk.get_objs_to_delete(req) - self.assertEquals(results, - [{'name': '1'}, {'name': '2'}, {'name': '3'}]) + self.assertEqual(results, + [{'name': '1'}, {'name': '2'}, {'name': '3'}]) with patch.object(self.bulk, 'max_deletes_per_request', 9): with patch.object(self.bulk, 'max_path_length', 1): @@ -727,15 +727,15 @@ class TestDelete(unittest.TestCase): headers={'Accept': 'application/json'}) req.method = 'POST' resp_body = self.handle_delete_and_iter(req) - self.assertEquals( + self.assertEqual( self.app.delete_paths, ['/delete_works/AUTH_Acc/c/f', '/delete_works/AUTH_Acc/c/f404', '/delete_works/AUTH_Acc/c/%25']) - self.assertEquals(self.app.calls, 3) + self.assertEqual(self.app.calls, 3) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 2) - self.assertEquals(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Number Deleted'], 2) + self.assertEqual(resp_data['Number Not Found'], 1) def test_bulk_delete_too_many_newlines(self): req = Request.blank('/delete_works/AUTH_Acc') @@ -754,20 +754,20 @@ class TestDelete(unittest.TestCase): headers={'Accept': 'application/json'}) req.method = 'POST' resp_body = self.handle_delete_and_iter(req) - self.assertEquals( + self.assertEqual( self.app.delete_paths, ['/delete_works/AUTH_Acc/c/ obj \xe2\x99\xa1', '/delete_works/AUTH_Acc/c/ objbadutf8']) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 1) - self.assertEquals(len(resp_data['Errors']), 2) - self.assertEquals(resp_data['Errors'], - [[urllib.parse.quote('c/ objbadutf8'), - '412 Precondition Failed'], - [urllib.parse.quote('/c/f\xdebadutf8'), - '412 Precondition Failed']]) + self.assertEqual(resp_data['Number Deleted'], 1) + self.assertEqual(len(resp_data['Errors']), 2) + self.assertEqual(resp_data['Errors'], + [[urllib.parse.quote('c/ objbadutf8'), + '412 Precondition Failed'], + [urllib.parse.quote('/c/f\xdebadutf8'), + '412 Precondition Failed']]) def test_bulk_delete_no_body(self): req = Request.blank('/unauth/AUTH_acc/') @@ -784,11 +784,11 @@ class TestDelete(unittest.TestCase): headers={'Accept': 'application/json'}) req.method = 'POST' resp_body = self.handle_delete_and_iter(req) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Errors'], [['/c/f', '401 Unauthorized']]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Number Deleted'], 1) + self.assertEqual(resp_data['Errors'], [['/c/f', '401 Unauthorized']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Number Deleted'], 1) def test_bulk_delete_500_resp(self): req = Request.blank('/broke/AUTH_acc/', body='/c/f\nc/f2\n', @@ -796,10 +796,10 @@ class TestDelete(unittest.TestCase): req.method = 'POST' resp_body = self.handle_delete_and_iter(req) resp_data = utils.json.loads(resp_body) - self.assertEquals( + self.assertEqual( resp_data['Errors'], [['/c/f', '500 Internal Error'], ['c/f2', '500 Internal Error']]) - self.assertEquals(resp_data['Response Status'], '502 Bad Gateway') + self.assertEqual(resp_data['Response Status'], '502 Bad Gateway') def test_bulk_delete_bad_path(self): req = Request.blank('/delete_cont_fail/') @@ -815,10 +815,10 @@ class TestDelete(unittest.TestCase): return_value=None)) as mock_sleep: resp_body = self.handle_delete_and_iter(req) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 0) - self.assertEquals(resp_data['Errors'], [['c', '409 Conflict']]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals([], mock_sleep.call_args_list) + self.assertEqual(resp_data['Number Deleted'], 0) + self.assertEqual(resp_data['Errors'], [['c', '409 Conflict']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual([], mock_sleep.call_args_list) def test_bulk_delete_container_delete_retry_and_fails(self): self.bulk.retry_count = 3 @@ -830,13 +830,13 @@ class TestDelete(unittest.TestCase): return_value=None)) as mock_sleep: resp_body = self.handle_delete_and_iter(req) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 0) - self.assertEquals(resp_data['Errors'], [['c', '409 Conflict']]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals([call(self.bulk.retry_interval), - call(self.bulk.retry_interval ** 2), - call(self.bulk.retry_interval ** 3)], - mock_sleep.call_args_list) + self.assertEqual(resp_data['Number Deleted'], 0) + self.assertEqual(resp_data['Errors'], [['c', '409 Conflict']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual([call(self.bulk.retry_interval), + call(self.bulk.retry_interval ** 2), + call(self.bulk.retry_interval ** 3)], + mock_sleep.call_args_list) def test_bulk_delete_container_delete_retry_and_success(self): self.bulk.retry_count = 3 @@ -849,12 +849,12 @@ class TestDelete(unittest.TestCase): return_value=None)) as mock_sleep: resp_body = self.handle_delete_and_iter(req) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 1) - self.assertEquals(resp_data['Errors'], []) - self.assertEquals(resp_data['Response Status'], '200 OK') - self.assertEquals([call(self.bulk.retry_interval), - call(self.bulk.retry_interval ** 2)], - mock_sleep.call_args_list) + self.assertEqual(resp_data['Number Deleted'], 1) + self.assertEqual(resp_data['Errors'], []) + self.assertEqual(resp_data['Response Status'], '200 OK') + self.assertEqual([call(self.bulk.retry_interval), + call(self.bulk.retry_interval ** 2)], + mock_sleep.call_args_list) def test_bulk_delete_bad_file_too_long(self): req = Request.blank('/delete_works/AUTH_Acc', @@ -866,9 +866,9 @@ class TestDelete(unittest.TestCase): req.headers['Transfer-Encoding'] = 'chunked' resp_body = self.handle_delete_and_iter(req) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Number Deleted'], 2) - self.assertEquals(resp_data['Errors'], [[bad_file, '400 Bad Request']]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Number Deleted'], 2) + self.assertEqual(resp_data['Errors'], [[bad_file, '400 Bad Request']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') def test_bulk_delete_bad_file_over_twice_max_length(self): body = '/c/f\nc/' + ('123456' * self.bulk.max_path_length) + '\n' @@ -883,14 +883,14 @@ class TestDelete(unittest.TestCase): req.method = 'POST' with patch.object(self.bulk, 'max_failed_deletes', 2): resp_body = self.handle_delete_and_iter(req) - self.assertEquals(self.app.calls, 2) + self.assertEqual(self.app.calls, 2) resp_data = utils.json.loads(resp_body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Response Body'], - 'Max delete failures exceeded') - self.assertEquals(resp_data['Errors'], - [['/c/f1', '401 Unauthorized'], - ['/c/f2', '401 Unauthorized']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Response Body'], + 'Max delete failures exceeded') + self.assertEqual(resp_data['Errors'], + [['/c/f1', '401 Unauthorized'], + ['/c/f2', '401 Unauthorized']]) class TestSwiftInfo(unittest.TestCase): diff --git a/test/unit/common/middleware/test_cname_lookup.py b/test/unit/common/middleware/test_cname_lookup.py index ba76c5546d..51c1dc1b59 100644 --- a/test/unit/common/middleware/test_cname_lookup.py +++ b/test/unit/common/middleware/test_cname_lookup.py @@ -55,12 +55,12 @@ class TestCNAMELookup(unittest.TestCase): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': '10.134.23.198'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'fc00:7ea1:f155::6321:8841'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') def test_passthrough(self): @@ -71,16 +71,16 @@ class TestCNAMELookup(unittest.TestCase): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'foo.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'foo.example.com:8080'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET', 'SERVER_NAME': 'foo.example.com'}, headers={'Host': None}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') def test_good_lookup(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, @@ -91,16 +91,16 @@ class TestCNAMELookup(unittest.TestCase): cname_lookup.lookup_cname = my_lookup resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'mysite.com:8080'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET', 'SERVER_NAME': 'mysite.com'}, headers={'Host': None}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') def test_lookup_chain_too_long(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, @@ -117,7 +117,7 @@ class TestCNAMELookup(unittest.TestCase): cname_lookup.lookup_cname = my_lookup resp = self.app(req.environ, start_response) - self.assertEquals(resp, ['CNAME lookup failed after 2 tries']) + self.assertEqual(resp, ['CNAME lookup failed after 2 tries']) def test_lookup_chain_bad_target(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, @@ -128,8 +128,8 @@ class TestCNAMELookup(unittest.TestCase): cname_lookup.lookup_cname = my_lookup resp = self.app(req.environ, start_response) - self.assertEquals(resp, - ['CNAME lookup failed to resolve to a valid domain']) + self.assertEqual(resp, + ['CNAME lookup failed to resolve to a valid domain']) def test_something_weird(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, @@ -140,8 +140,8 @@ class TestCNAMELookup(unittest.TestCase): cname_lookup.lookup_cname = my_lookup resp = self.app(req.environ, start_response) - self.assertEquals(resp, - ['CNAME lookup failed to resolve to a valid domain']) + self.assertEqual(resp, + ['CNAME lookup failed to resolve to a valid domain']) def test_with_memcache(self): def my_lookup(d): @@ -162,12 +162,12 @@ class TestCNAMELookup(unittest.TestCase): 'swift.cache': memcache}, headers={'Host': 'mysite.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET', 'swift.cache': memcache}, headers={'Host': 'mysite.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') def test_cname_matching_ending_not_domain(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, @@ -178,8 +178,8 @@ class TestCNAMELookup(unittest.TestCase): cname_lookup.lookup_cname = my_lookup resp = self.app(req.environ, start_response) - self.assertEquals(resp, - ['CNAME lookup failed to resolve to a valid domain']) + self.assertEqual(resp, + ['CNAME lookup failed to resolve to a valid domain']) def test_cname_configured_with_empty_storage_domain(self): app = cname_lookup.CNAMELookupMiddleware(FakeApp(), @@ -193,28 +193,28 @@ class TestCNAMELookup(unittest.TestCase): cname_lookup.lookup_cname = my_lookup resp = app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') def test_storage_domains_conf_format(self): conf = {'storage_domain': 'foo.com'} app = cname_lookup.filter_factory(conf)(FakeApp()) - self.assertEquals(app.storage_domain, ['.foo.com']) + self.assertEqual(app.storage_domain, ['.foo.com']) conf = {'storage_domain': 'foo.com, '} app = cname_lookup.filter_factory(conf)(FakeApp()) - self.assertEquals(app.storage_domain, ['.foo.com']) + self.assertEqual(app.storage_domain, ['.foo.com']) conf = {'storage_domain': 'foo.com, bar.com'} app = cname_lookup.filter_factory(conf)(FakeApp()) - self.assertEquals(app.storage_domain, ['.foo.com', '.bar.com']) + self.assertEqual(app.storage_domain, ['.foo.com', '.bar.com']) conf = {'storage_domain': 'foo.com, .bar.com'} app = cname_lookup.filter_factory(conf)(FakeApp()) - self.assertEquals(app.storage_domain, ['.foo.com', '.bar.com']) + self.assertEqual(app.storage_domain, ['.foo.com', '.bar.com']) conf = {'storage_domain': '.foo.com, .bar.com'} app = cname_lookup.filter_factory(conf)(FakeApp()) - self.assertEquals(app.storage_domain, ['.foo.com', '.bar.com']) + self.assertEqual(app.storage_domain, ['.foo.com', '.bar.com']) def test_multiple_storage_domains(self): conf = {'storage_domain': 'storage1.com, storage2.com', @@ -229,11 +229,11 @@ class TestCNAMELookup(unittest.TestCase): return app(req.environ, start_response) resp = do_test('c.storage1.com') - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') resp = do_test('c.storage2.com') - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') bad_domain = ['CNAME lookup failed to resolve to a valid domain'] resp = do_test('c.badtest.com') - self.assertEquals(resp, bad_domain) + self.assertEqual(resp, bad_domain) diff --git a/test/unit/common/middleware/test_crossdomain.py b/test/unit/common/middleware/test_crossdomain.py index c5c0ca68e6..aa08c94cca 100644 --- a/test/unit/common/middleware/test_crossdomain.py +++ b/test/unit/common/middleware/test_crossdomain.py @@ -47,7 +47,7 @@ class TestCrossDomain(unittest.TestCase): req = Request.blank('/crossdomain.xml', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, [expectedResponse]) + self.assertEqual(resp, [expectedResponse]) # GET of /crossdomain.xml (custom) def test_crossdomain_custom(self): @@ -64,13 +64,13 @@ class TestCrossDomain(unittest.TestCase): req = Request.blank('/crossdomain.xml', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, [expectedResponse]) + self.assertEqual(resp, [expectedResponse]) # GET to a different resource should be passed on def test_crossdomain_pass(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') # Only GET is allowed on the /crossdomain.xml resource def test_crossdomain_get_only(self): @@ -78,7 +78,7 @@ class TestCrossDomain(unittest.TestCase): req = Request.blank('/crossdomain.xml', environ={'REQUEST_METHOD': method}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') if __name__ == '__main__': diff --git a/test/unit/common/middleware/test_domain_remap.py b/test/unit/common/middleware/test_domain_remap.py index 225e947a76..d02327ddfd 100644 --- a/test/unit/common/middleware/test_domain_remap.py +++ b/test/unit/common/middleware/test_domain_remap.py @@ -40,72 +40,72 @@ class TestDomainRemap(unittest.TestCase): 'SERVER_NAME': 'example.com'}, headers={'Host': None}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/') + self.assertEqual(resp, '/') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/') + self.assertEqual(resp, '/') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'example.com:8080'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/') + self.assertEqual(resp, '/') def test_domain_remap_account(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET', 'SERVER_NAME': 'AUTH_a.example.com'}, headers={'Host': None}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a') + self.assertEqual(resp, '/v1/AUTH_a') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a') + self.assertEqual(resp, '/v1/AUTH_a') req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'AUTH-uuid.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_uuid') + self.assertEqual(resp, '/v1/AUTH_uuid') def test_domain_remap_account_container(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a/c') + self.assertEqual(resp, '/v1/AUTH_a/c') def test_domain_remap_extra_subdomains(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'x.y.c.AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, ['Bad domain in host header']) + self.assertEqual(resp, ['Bad domain in host header']) def test_domain_remap_account_with_path_root(self): req = Request.blank('/v1', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a') + self.assertEqual(resp, '/v1/AUTH_a') def test_domain_remap_account_container_with_path_root(self): req = Request.blank('/v1', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a/c') + self.assertEqual(resp, '/v1/AUTH_a/c') def test_domain_remap_account_container_with_path(self): req = Request.blank('/obj', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a/c/obj') + self.assertEqual(resp, '/v1/AUTH_a/c/obj') def test_domain_remap_account_container_with_path_root_and_path(self): req = Request.blank('/v1/obj', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_a/c/obj') + self.assertEqual(resp, '/v1/AUTH_a/c/obj') def test_domain_remap_account_matching_ending_not_domain(self): req = Request.blank('/dontchange', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.aexample.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/dontchange') + self.assertEqual(resp, '/dontchange') def test_domain_remap_configured_with_empty_storage_domain(self): self.app = domain_remap.DomainRemapMiddleware(FakeApp(), @@ -113,7 +113,7 @@ class TestDomainRemap(unittest.TestCase): req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.AUTH_a.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/test') + self.assertEqual(resp, '/test') def test_domain_remap_configured_with_prefixes(self): conf = {'reseller_prefixes': 'PREFIX'} @@ -121,7 +121,7 @@ class TestDomainRemap(unittest.TestCase): req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.prefix_uuid.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/PREFIX_uuid/c/test') + self.assertEqual(resp, '/v1/PREFIX_uuid/c/test') def test_domain_remap_configured_with_bad_prefixes(self): conf = {'reseller_prefixes': 'UNKNOWN'} @@ -129,7 +129,7 @@ class TestDomainRemap(unittest.TestCase): req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.prefix_uuid.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/test') + self.assertEqual(resp, '/test') def test_domain_remap_configured_with_no_prefixes(self): conf = {'reseller_prefixes': ''} @@ -137,7 +137,7 @@ class TestDomainRemap(unittest.TestCase): req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'c.uuid.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/uuid/c/test') + self.assertEqual(resp, '/v1/uuid/c/test') def test_domain_remap_add_prefix(self): conf = {'default_reseller_prefix': 'FOO'} @@ -145,7 +145,7 @@ class TestDomainRemap(unittest.TestCase): req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'uuid.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/FOO_uuid/test') + self.assertEqual(resp, '/v1/FOO_uuid/test') def test_domain_remap_add_prefix_already_there(self): conf = {'default_reseller_prefix': 'AUTH'} @@ -153,7 +153,7 @@ class TestDomainRemap(unittest.TestCase): req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'}, headers={'Host': 'auth-uuid.example.com'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, '/v1/AUTH_uuid/test') + self.assertEqual(resp, '/v1/AUTH_uuid/test') class TestSwiftInfo(unittest.TestCase): @@ -172,7 +172,7 @@ class TestSwiftInfo(unittest.TestCase): domain_remap.filter_factory({'default_reseller_prefix': 'cupcake'}) swift_info = utils.get_swift_info() self.assertTrue('domain_remap' in swift_info) - self.assertEquals( + self.assertEqual( swift_info['domain_remap'].get('default_reseller_prefix'), 'cupcake') diff --git a/test/unit/common/middleware/test_except.py b/test/unit/common/middleware/test_except.py index dd2dd667ab..494887224c 100644 --- a/test/unit/common/middleware/test_except.py +++ b/test/unit/common/middleware/test_except.py @@ -57,43 +57,43 @@ class TestCatchErrors(unittest.TestCase): app = catch_errors.CatchErrorMiddleware(FakeApp(), {}) req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = app(req.environ, start_response) - self.assertEquals(list(resp), ['FAKE APP']) + self.assertEqual(list(resp), ['FAKE APP']) def test_catcherrors(self): app = catch_errors.CatchErrorMiddleware(FakeApp(True), {}) req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = app(req.environ, start_response) - self.assertEquals(list(resp), ['An error occurred']) + self.assertEqual(list(resp), ['An error occurred']) def test_trans_id_header_pass(self): - self.assertEquals(self.logger.txn_id, None) + self.assertEqual(self.logger.txn_id, None) def start_response(status, headers, exc_info=None): self.assertTrue('X-Trans-Id' in (x[0] for x in headers)) app = catch_errors.CatchErrorMiddleware(FakeApp(), {}) req = Request.blank('/v1/a/c/o') app(req.environ, start_response) - self.assertEquals(len(self.logger.txn_id), 34) # 32 hex + 'tx' + self.assertEqual(len(self.logger.txn_id), 34) # 32 hex + 'tx' def test_trans_id_header_fail(self): - self.assertEquals(self.logger.txn_id, None) + self.assertEqual(self.logger.txn_id, None) def start_response(status, headers, exc_info=None): self.assertTrue('X-Trans-Id' in (x[0] for x in headers)) app = catch_errors.CatchErrorMiddleware(FakeApp(True), {}) req = Request.blank('/v1/a/c/o') app(req.environ, start_response) - self.assertEquals(len(self.logger.txn_id), 34) + self.assertEqual(len(self.logger.txn_id), 34) def test_error_in_iterator(self): app = catch_errors.CatchErrorMiddleware( FakeApp(body_iter=(int(x) for x in 'abcd')), {}) req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = app(req.environ, start_response) - self.assertEquals(list(resp), ['An error occurred']) + self.assertEqual(list(resp), ['An error occurred']) def test_trans_id_header_suffix(self): - self.assertEquals(self.logger.txn_id, None) + self.assertEqual(self.logger.txn_id, None) def start_response(status, headers, exc_info=None): self.assertTrue('X-Trans-Id' in (x[0] for x in headers)) @@ -104,7 +104,7 @@ class TestCatchErrors(unittest.TestCase): self.assertTrue(self.logger.txn_id.endswith('-stuff')) def test_trans_id_header_extra(self): - self.assertEquals(self.logger.txn_id, None) + self.assertEqual(self.logger.txn_id, None) def start_response(status, headers, exc_info=None): self.assertTrue('X-Trans-Id' in (x[0] for x in headers)) @@ -116,7 +116,7 @@ class TestCatchErrors(unittest.TestCase): self.assertTrue(self.logger.txn_id.endswith('-fromconf-fromuser')) def test_trans_id_header_extra_length_limit(self): - self.assertEquals(self.logger.txn_id, None) + self.assertEqual(self.logger.txn_id, None) def start_response(status, headers, exc_info=None): self.assertTrue('X-Trans-Id' in (x[0] for x in headers)) @@ -129,7 +129,7 @@ class TestCatchErrors(unittest.TestCase): '-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) def test_trans_id_header_extra_quoted(self): - self.assertEquals(self.logger.txn_id, None) + self.assertEqual(self.logger.txn_id, None) def start_response(status, headers, exc_info=None): self.assertTrue('X-Trans-Id' in (x[0] for x in headers)) @@ -143,7 +143,7 @@ class TestCatchErrors(unittest.TestCase): app = catch_errors.CatchErrorMiddleware(FakeApp(error='strange'), {}) req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = app(req.environ, start_response) - self.assertEquals(list(resp), ['An error occurred']) + self.assertEqual(list(resp), ['An error occurred']) if __name__ == '__main__': diff --git a/test/unit/common/middleware/test_formpost.py b/test/unit/common/middleware/test_formpost.py index 6b7ecead17..4e6f24826f 100644 --- a/test/unit/common/middleware/test_formpost.py +++ b/test/unit/common/middleware/test_formpost.py @@ -73,7 +73,7 @@ class FakeApp(object): class TestCappedFileLikeObject(unittest.TestCase): def test_whole(self): - self.assertEquals( + self.assertEqual( formpost._CappedFileLikeObject(BytesIO(b'abc'), 10).read(), b'abc') @@ -83,31 +83,31 @@ class TestCappedFileLikeObject(unittest.TestCase): formpost._CappedFileLikeObject(BytesIO(b'abc'), 2).read() except EOFError as err: exc = err - self.assertEquals(str(exc), 'max_file_size exceeded') + self.assertEqual(str(exc), 'max_file_size exceeded') def test_whole_readline(self): fp = formpost._CappedFileLikeObject(BytesIO(b'abc\ndef'), 10) - self.assertEquals(fp.readline(), b'abc\n') - self.assertEquals(fp.readline(), b'def') - self.assertEquals(fp.readline(), b'') + self.assertEqual(fp.readline(), b'abc\n') + self.assertEqual(fp.readline(), b'def') + self.assertEqual(fp.readline(), b'') def test_exceeded_readline(self): fp = formpost._CappedFileLikeObject(BytesIO(b'abc\ndef'), 5) - self.assertEquals(fp.readline(), b'abc\n') + self.assertEqual(fp.readline(), b'abc\n') exc = None try: - self.assertEquals(fp.readline(), b'def') + self.assertEqual(fp.readline(), b'def') except EOFError as err: exc = err - self.assertEquals(str(exc), 'max_file_size exceeded') + self.assertEqual(str(exc), 'max_file_size exceeded') def test_read_sized(self): fp = formpost._CappedFileLikeObject(BytesIO(b'abcdefg'), 10) - self.assertEquals(fp.read(2), b'ab') - self.assertEquals(fp.read(2), b'cd') - self.assertEquals(fp.read(2), b'ef') - self.assertEquals(fp.read(2), b'g') - self.assertEquals(fp.read(2), b'') + self.assertEqual(fp.read(2), b'ab') + self.assertEqual(fp.read(2), b'cd') + self.assertEqual(fp.read(2), b'ef') + self.assertEqual(fp.read(2), b'g') + self.assertEqual(fp.read(2), b'') class TestFormPost(unittest.TestCase): @@ -238,7 +238,7 @@ class TestFormPost(unittest.TestCase): resp = self._make_request( '/v1/a/c/o', environ={'REQUEST_METHOD': method}).get_response(self.formpost) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('FormPost' not in resp.body) def test_auth_scheme(self): @@ -266,13 +266,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') authenticate_v = None for h, v in headers: if h.lower() == 'www-authenticate': authenticate_v = v self.assertTrue('FormPost: Form Expired' in body) - self.assertEquals('Swift realm="unknown"', authenticate_v) + self.assertEqual('Swift realm="unknown"', authenticate_v) def test_safari(self): key = 'abc' @@ -379,17 +379,17 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, 'http://brim.net?status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, 'http://brim.net?status=201&message=') + self.assertEqual(exc_info, None) self.assertTrue('http://brim.net?status=201&message=' in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_firefox(self): key = 'abc' @@ -495,17 +495,17 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, 'http://brim.net?status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, 'http://brim.net?status=201&message=') + self.assertEqual(exc_info, None) self.assertTrue('http://brim.net?status=201&message=' in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_chrome(self): key = 'abc' @@ -614,17 +614,17 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, 'http://brim.net?status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, 'http://brim.net?status=201&message=') + self.assertEqual(exc_info, None) self.assertTrue('http://brim.net?status=201&message=' in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_explorer(self): key = 'abc' @@ -729,17 +729,17 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, 'http://brim.net?status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, 'http://brim.net?status=201&message=') + self.assertEqual(exc_info, None) self.assertTrue('http://brim.net?status=201&message=' in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_messed_up_start(self): key = 'abc' @@ -772,10 +772,10 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '400 Bad Request') - self.assertEquals(exc_info, None) + self.assertEqual(status, '400 Bad Request') + self.assertEqual(exc_info, None) self.assertTrue('FormPost: invalid starting boundary' in body) - self.assertEquals(len(self.app.requests), 0) + self.assertEqual(len(self.app.requests), 0) def test_max_file_size_exceeded(self): key = 'abc' @@ -803,10 +803,10 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '400 Bad Request') - self.assertEquals(exc_info, None) + self.assertEqual(status, '400 Bad Request') + self.assertEqual(exc_info, None) self.assertTrue('FormPost: max_file_size exceeded' in body) - self.assertEquals(len(self.app.requests), 0) + self.assertEqual(len(self.app.requests), 0) def test_max_file_count_exceeded(self): key = 'abc' @@ -834,20 +834,20 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals( + self.assertEqual( location, 'http://brim.net?status=400&message=max%20file%20count%20exceeded') - self.assertEquals(exc_info, None) + self.assertEqual(exc_info, None) self.assertTrue( 'http://brim.net?status=400&message=max%20file%20count%20exceeded' in body) - self.assertEquals(len(self.app.requests), 1) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(len(self.app.requests), 1) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') def test_subrequest_does_not_pass_query(self): key = 'abc' @@ -879,10 +879,10 @@ class TestFormPost(unittest.TestCase): exc_info = exc_info[0] # Make sure we 201 Created, which means we made the final subrequest # (and FakeApp verifies that no QUERY_STRING got passed). - self.assertEquals(status, '201 Created') - self.assertEquals(exc_info, None) + self.assertEqual(status, '201 Created') + self.assertEqual(exc_info, None) self.assertTrue('201 Created' in body) - self.assertEquals(len(self.app.requests), 2) + self.assertEqual(len(self.app.requests), 2) def test_subrequest_fails(self): key = 'abc' @@ -910,15 +910,15 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, 'http://brim.net?status=404&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, 'http://brim.net?status=404&message=') + self.assertEqual(exc_info, None) self.assertTrue('http://brim.net?status=404&message=' in body) - self.assertEquals(len(self.app.requests), 1) + self.assertEqual(len(self.app.requests), 1) def test_truncated_attr_value(self): key = 'abc' @@ -996,20 +996,20 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals( + self.assertEqual( location, ('a' * formpost.MAX_VALUE_LENGTH) + '?status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(exc_info, None) self.assertTrue( ('a' * formpost.MAX_VALUE_LENGTH) + '?status=201&message=' in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_no_file_to_process(self): key = 'abc' @@ -1067,19 +1067,19 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals( + self.assertEqual( location, 'http://brim.net?status=400&message=no%20files%20to%20process') - self.assertEquals(exc_info, None) + self.assertEqual(exc_info, None) self.assertTrue( 'http://brim.net?status=400&message=no%20files%20to%20process' in body) - self.assertEquals(len(self.app.requests), 0) + self.assertEqual(len(self.app.requests), 0) def test_formpost_without_useragent(self): key = 'abc' @@ -1099,8 +1099,8 @@ class TestFormPost(unittest.TestCase): pass body = ''.join(self.formpost(env, start_response)) self.assertTrue('User-Agent' in self.app.requests[0].headers) - self.assertEquals(self.app.requests[0].headers['User-Agent'], - 'FormPost') + self.assertEqual(self.app.requests[0].headers['User-Agent'], + 'FormPost') def test_formpost_with_origin(self): key = 'abc' @@ -1127,8 +1127,8 @@ class TestFormPost(unittest.TestCase): pass body = ''.join(self.formpost(env, start_response)) - self.assertEquals(headers['Access-Control-Allow-Origin'], - 'http://localhost:5000') + self.assertEqual(headers['Access-Control-Allow-Origin'], + 'http://localhost:5000') def test_formpost_with_multiple_keys(self): key = 'ernie' @@ -1219,17 +1219,17 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, 'http://redirect?status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, 'http://redirect?status=201&message=') + self.assertEqual(exc_info, None) self.assertTrue(location in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_redirect_with_query(self): key = 'abc' @@ -1257,18 +1257,18 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '303 See Other') + self.assertEqual(status, '303 See Other') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, - 'http://redirect?one=two&status=201&message=') - self.assertEquals(exc_info, None) + self.assertEqual(location, + 'http://redirect?one=two&status=201&message=') + self.assertEqual(exc_info, None) self.assertTrue(location in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_no_redirect(self): key = 'abc' @@ -1295,17 +1295,17 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '201 Created') + self.assertEqual(status, '201 Created') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('201 Created' in body) - self.assertEquals(len(self.app.requests), 2) - self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n') - self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n') + self.assertEqual(len(self.app.requests), 2) + self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') + self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n') def test_no_redirect_expired(self): key = 'abc' @@ -1331,13 +1331,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Form Expired' in body) def test_no_redirect_invalid_sig(self): @@ -1365,13 +1365,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Invalid Signature' in body) def test_no_redirect_with_error(self): @@ -1398,13 +1398,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '400 Bad Request') + self.assertEqual(status, '400 Bad Request') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: invalid starting boundary' in body) def test_no_v1(self): @@ -1431,13 +1431,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Invalid Signature' in body) def test_empty_v1(self): @@ -1464,13 +1464,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Invalid Signature' in body) def test_empty_account(self): @@ -1497,13 +1497,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Invalid Signature' in body) def test_wrong_account(self): @@ -1532,13 +1532,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Invalid Signature' in body) def test_no_container(self): @@ -1565,13 +1565,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '401 Unauthorized') + self.assertEqual(status, '401 Unauthorized') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: Invalid Signature' in body) def test_completely_non_int_expires(self): @@ -1603,13 +1603,13 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '400 Bad Request') + self.assertEqual(status, '400 Bad Request') location = None for h, v in headers: if h.lower() == 'location': location = v - self.assertEquals(location, None) - self.assertEquals(exc_info, None) + self.assertEqual(location, None) + self.assertEqual(exc_info, None) self.assertTrue('FormPost: expired not an integer' in body) def test_x_delete_at(self): @@ -1645,15 +1645,15 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '201 Created') + self.assertEqual(status, '201 Created') self.assertTrue('201 Created' in body) - self.assertEquals(len(self.app.requests), 2) + self.assertEqual(len(self.app.requests), 2) self.assertTrue("X-Delete-At" in self.app.requests[0].headers) self.assertTrue("X-Delete-At" in self.app.requests[1].headers) - self.assertEquals(delete_at, - self.app.requests[0].headers["X-Delete-At"]) - self.assertEquals(delete_at, - self.app.requests[1].headers["X-Delete-At"]) + self.assertEqual(delete_at, + self.app.requests[0].headers["X-Delete-At"]) + self.assertEqual(delete_at, + self.app.requests[1].headers["X-Delete-At"]) def test_x_delete_at_not_int(self): delete_at = "2014-07-16" @@ -1687,7 +1687,7 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '400 Bad Request') + self.assertEqual(status, '400 Bad Request') self.assertTrue('FormPost: x_delete_at not an integer' in body) def test_x_delete_after(self): @@ -1723,9 +1723,9 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '201 Created') + self.assertEqual(status, '201 Created') self.assertTrue('201 Created' in body) - self.assertEquals(len(self.app.requests), 2) + self.assertEqual(len(self.app.requests), 2) self.assertTrue("X-Delete-After" in self.app.requests[0].headers) self.assertTrue("X-Delete-After" in self.app.requests[1].headers) self.assertEqual(delete_after, @@ -1765,7 +1765,7 @@ class TestFormPost(unittest.TestCase): status = status[0] headers = headers[0] exc_info = exc_info[0] - self.assertEquals(status, '400 Bad Request') + self.assertEqual(status, '400 Bad Request') self.assertTrue('FormPost: x_delete_after not an integer' in body) diff --git a/test/unit/common/middleware/test_gatekeeper.py b/test/unit/common/middleware/test_gatekeeper.py index e4109b0c3d..42d88e6abd 100644 --- a/test/unit/common/middleware/test_gatekeeper.py +++ b/test/unit/common/middleware/test_gatekeeper.py @@ -99,8 +99,8 @@ class TestGatekeeper(unittest.TestCase): fake_app = FakeApp() app = self.get_app(fake_app, {}) resp = req.get_response(app) - self.assertEquals('200 OK', resp.status) - self.assertEquals(resp.body, 'FAKE APP') + self.assertEqual('200 OK', resp.status) + self.assertEqual(resp.body, 'FAKE APP') self._assertHeadersEqual(self.allowed_headers, fake_app.req.headers) def _test_reserved_header_removed_inbound(self, method): @@ -111,7 +111,7 @@ class TestGatekeeper(unittest.TestCase): fake_app = FakeApp() app = self.get_app(fake_app, {}) resp = req.get_response(app) - self.assertEquals('200 OK', resp.status) + self.assertEqual('200 OK', resp.status) self._assertHeadersEqual(self.allowed_headers, fake_app.req.headers) self._assertHeadersAbsent(self.forbidden_headers_in, fake_app.req.headers) @@ -127,7 +127,7 @@ class TestGatekeeper(unittest.TestCase): fake_app = FakeApp(headers=headers) app = self.get_app(fake_app, {}) resp = req.get_response(app) - self.assertEquals('200 OK', resp.status) + self.assertEqual('200 OK', resp.status) self._assertHeadersEqual(self.allowed_headers, resp.headers) self._assertHeadersAbsent(self.forbidden_headers_out, resp.headers) diff --git a/test/unit/common/middleware/test_healthcheck.py b/test/unit/common/middleware/test_healthcheck.py index 2cd6faf79e..3f95c6b2a8 100644 --- a/test/unit/common/middleware/test_healthcheck.py +++ b/test/unit/common/middleware/test_healthcheck.py @@ -50,30 +50,30 @@ class TestHealthCheck(unittest.TestCase): req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'}) app = self.get_app(FakeApp(), {}) resp = app(req.environ, self.start_response) - self.assertEquals(['200 OK'], self.got_statuses) - self.assertEquals(resp, ['OK']) + self.assertEqual(['200 OK'], self.got_statuses) + self.assertEqual(resp, ['OK']) def test_healtcheck_pass(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) app = self.get_app(FakeApp(), {}) resp = app(req.environ, self.start_response) - self.assertEquals(['200 OK'], self.got_statuses) - self.assertEquals(resp, ['FAKE APP']) + self.assertEqual(['200 OK'], self.got_statuses) + self.assertEqual(resp, ['FAKE APP']) def test_healthcheck_pass_not_disabled(self): req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'}) app = self.get_app(FakeApp(), {}, disable_path=self.disable_path) resp = app(req.environ, self.start_response) - self.assertEquals(['200 OK'], self.got_statuses) - self.assertEquals(resp, ['OK']) + self.assertEqual(['200 OK'], self.got_statuses) + self.assertEqual(resp, ['OK']) def test_healthcheck_pass_disabled(self): open(self.disable_path, 'w') req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'}) app = self.get_app(FakeApp(), {}, disable_path=self.disable_path) resp = app(req.environ, self.start_response) - self.assertEquals(['503 Service Unavailable'], self.got_statuses) - self.assertEquals(resp, ['DISABLED BY FILE']) + self.assertEqual(['503 Service Unavailable'], self.got_statuses) + self.assertEqual(resp, ['DISABLED BY FILE']) if __name__ == '__main__': diff --git a/test/unit/common/middleware/test_keystoneauth.py b/test/unit/common/middleware/test_keystoneauth.py index da9530a063..24dd1a0d8d 100644 --- a/test/unit/common/middleware/test_keystoneauth.py +++ b/test/unit/common/middleware/test_keystoneauth.py @@ -205,7 +205,7 @@ class SwiftAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_account', environ={'swift.authorize_override': True}) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) def test_override_asked_for_and_allowed(self): conf = {'allow_overrides': 'true'} @@ -213,13 +213,13 @@ class SwiftAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_account', environ={'swift.authorize_override': True}) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_override_default_allowed(self): req = self._make_request('/v1/AUTH_account', environ={'swift.authorize_override': True}) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_anonymous_options_allowed(self): req = self._make_request('/v1/AUTH_account', @@ -611,7 +611,7 @@ class TestAuthorize(BaseTestAuthorize): if exception and not result: self.fail("error %s was not returned" % (str(exception))) elif exception: - self.assertEquals(result.status_int, exception) + self.assertEqual(result.status_int, exception) else: self.assertTrue(result is None) return req @@ -928,7 +928,7 @@ class TestAuthorize(BaseTestAuthorize): 'roles': list(roles)} data = self.test_auth._keystone_identity(req.environ) - self.assertEquals(expected, data) + self.assertEqual(expected, data) def test_integral_keystone_identity(self): user = ('U_ID', 'U_NAME') @@ -967,7 +967,7 @@ class TestAuthorize(BaseTestAuthorize): 'project_domain': (None, None), 'auth_version': 0} data = self.test_auth._integral_keystone_identity(req.environ) - self.assertEquals(expected, data) + self.assertEqual(expected, data) # v2 token info in environ req.environ['keystone.token_info'] = _fake_token_info(version='2') @@ -979,7 +979,7 @@ class TestAuthorize(BaseTestAuthorize): 'project_domain': (None, None), 'auth_version': 2} data = self.test_auth._integral_keystone_identity(req.environ) - self.assertEquals(expected, data) + self.assertEqual(expected, data) # v3 token info in environ req.environ['keystone.token_info'] = _fake_token_info(version='3') @@ -991,7 +991,7 @@ class TestAuthorize(BaseTestAuthorize): 'project_domain': project_domain, 'auth_version': 3} data = self.test_auth._integral_keystone_identity(req.environ) - self.assertEquals(expected, data) + self.assertEqual(expected, data) # service token in environ req.headers.update({'X-Service-Roles': '%s,%s' % service_roles}) @@ -1003,7 +1003,7 @@ class TestAuthorize(BaseTestAuthorize): 'project_domain': project_domain, 'auth_version': 3} data = self.test_auth._integral_keystone_identity(req.environ) - self.assertEquals(expected, data) + self.assertEqual(expected, data) def test_get_project_domain_id(self): sysmeta = {} diff --git a/test/unit/common/middleware/test_list_endpoints.py b/test/unit/common/middleware/test_list_endpoints.py index 00dd426b93..cc78e8f479 100644 --- a/test/unit/common/middleware/test_list_endpoints.py +++ b/test/unit/common/middleware/test_list_endpoints.py @@ -112,8 +112,8 @@ class TestListEndpoints(unittest.TestCase): info['storage_policy'] = self.policy_to_test (version, account, container, unused) = \ split_path(env['PATH_INFO'], 3, 4, True) - self.assertEquals((version, account, container), - self.expected_path[:3]) + self.assertEqual((version, account, container), + self.expected_path[:3]) return info def test_parse_response_version(self): @@ -194,10 +194,10 @@ class TestListEndpoints(unittest.TestCase): self.assertEqual(obj, None) def test_get_object_ring(self): - self.assertEquals(isinstance(self.list_endpoints.get_object_ring(0), - ring.Ring), True) - self.assertEquals(isinstance(self.list_endpoints.get_object_ring(1), - ring.Ring), True) + self.assertEqual(isinstance(self.list_endpoints.get_object_ring(0), + ring.Ring), True) + self.assertEqual(isinstance(self.list_endpoints.get_object_ring(1), + ring.Ring), True) self.assertRaises(ValueError, self.list_endpoints.get_object_ring, 99) def test_parse_path_no_version_specified(self): @@ -238,9 +238,9 @@ class TestListEndpoints(unittest.TestCase): # ring.get_nodes(). resp = Request.blank('/endpoints/a/c/o1').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'application/json') + self.assertEqual(json.loads(resp.body), [ "http://10.1.1.1:6000/sdb1/1/a/c/o1", "http://10.1.2.2:6000/sdd1/1/a/c/o1" ]) @@ -258,31 +258,31 @@ class TestListEndpoints(unittest.TestCase): with mock.patch(PATCHGI, self.FakeGetInfo): resp = Request.blank('/endpoints/a/c/o1').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(json.loads(resp.body), expected[pol.idx]) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'application/json') + self.assertEqual(json.loads(resp.body), expected[pol.idx]) # Here, 'o1/' is the object name. resp = Request.blank('/endpoints/a/c/o1/').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(json.loads(resp.body), [ "http://10.1.1.1:6000/sdb1/3/a/c/o1/", "http://10.1.2.2:6000/sdd1/3/a/c/o1/" ]) resp = Request.blank('/endpoints/a/c2').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(json.loads(resp.body), [ "http://10.1.1.1:6000/sda1/2/a/c2", "http://10.1.2.1:6000/sdc1/2/a/c2" ]) resp = Request.blank('/endpoints/a1').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(json.loads(resp.body), [ "http://10.1.2.1:6000/sdc1/0/a1", "http://10.1.1.1:6000/sda1/0/a1", "http://10.1.1.1:6000/sdb1/0/a1" @@ -290,43 +290,43 @@ class TestListEndpoints(unittest.TestCase): resp = Request.blank('/endpoints/').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) resp = Request.blank('/endpoints/a/c 2').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(json.loads(resp.body), [ "http://10.1.1.1:6000/sdb1/3/a/c%202", "http://10.1.2.2:6000/sdd1/3/a/c%202" ]) resp = Request.blank('/endpoints/a/c%202').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(json.loads(resp.body), [ "http://10.1.1.1:6000/sdb1/3/a/c%202", "http://10.1.2.2:6000/sdd1/3/a/c%202" ]) resp = Request.blank('/endpoints/ac%20count/con%20tainer/ob%20ject') \ .get_response(self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(json.loads(resp.body), [ + self.assertEqual(resp.status_int, 200) + self.assertEqual(json.loads(resp.body), [ "http://10.1.1.1:6000/sdb1/3/ac%20count/con%20tainer/ob%20ject", "http://10.1.2.2:6000/sdd1/3/ac%20count/con%20tainer/ob%20ject" ]) resp = Request.blank('/endpoints/a/c/o1', {'REQUEST_METHOD': 'POST'}) \ .get_response(self.list_endpoints) - self.assertEquals(resp.status_int, 405) - self.assertEquals(resp.status, '405 Method Not Allowed') - self.assertEquals(resp.headers['allow'], 'GET') + self.assertEqual(resp.status_int, 405) + self.assertEqual(resp.status, '405 Method Not Allowed') + self.assertEqual(resp.headers['allow'], 'GET') resp = Request.blank('/not-endpoints').get_response( self.list_endpoints) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.status, '200 OK') - self.assertEquals(resp.body, 'FakeApp') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.status, '200 OK') + self.assertEqual(resp.body, 'FakeApp') # test policies with custom endpoint name for pol in POLICIES: @@ -339,9 +339,9 @@ class TestListEndpoints(unittest.TestCase): with mock.patch(PATCHGI, self.FakeGetInfo): resp = Request.blank('/some/another/path/a/c/o1') \ .get_response(custom_path_le) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(json.loads(resp.body), expected[pol.idx]) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'application/json') + self.assertEqual(json.loads(resp.body), expected[pol.idx]) # test custom path without trailing slash custom_path_le = list_endpoints.filter_factory({ @@ -352,9 +352,9 @@ class TestListEndpoints(unittest.TestCase): with mock.patch(PATCHGI, self.FakeGetInfo): resp = Request.blank('/some/another/path/a/c/o1') \ .get_response(custom_path_le) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(json.loads(resp.body), expected[pol.idx]) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'application/json') + self.assertEqual(json.loads(resp.body), expected[pol.idx]) def test_v1_response(self): req = Request.blank('/endpoints/v1/a/c/o1') diff --git a/test/unit/common/middleware/test_memcache.py b/test/unit/common/middleware/test_memcache.py index 44c4fc3987..286b707e2a 100644 --- a/test/unit/common/middleware/test_memcache.py +++ b/test/unit/common/middleware/test_memcache.py @@ -126,13 +126,13 @@ class TestCacheMiddleware(unittest.TestCase): try: memcache.MemcacheMiddleware(FakeApp(), d) except Exception as err: - self.assertEquals( + self.assertEqual( str(err), "read called with '/etc/swift/memcache.conf'") count += 1 finally: memcache.ConfigParser = orig_parser - self.assertEquals(count, 7) + self.assertEqual(count, 7) def test_conf_set_no_read(self): orig_parser = memcache.ConfigParser @@ -147,7 +147,7 @@ class TestCacheMiddleware(unittest.TestCase): exc = err finally: memcache.ConfigParser = orig_parser - self.assertEquals(exc, None) + self.assertEqual(exc, None) def test_conf_default(self): orig_parser = memcache.ConfigParser @@ -156,10 +156,10 @@ class TestCacheMiddleware(unittest.TestCase): app = memcache.MemcacheMiddleware(FakeApp(), {}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '127.0.0.1:11211') - self.assertEquals(app.memcache._allow_pickle, False) - self.assertEquals(app.memcache._allow_unpickle, False) - self.assertEquals( + self.assertEqual(app.memcache_servers, '127.0.0.1:11211') + self.assertEqual(app.memcache._allow_pickle, False) + self.assertEqual(app.memcache._allow_unpickle, False) + self.assertEqual( app.memcache._client_cache['127.0.0.1:11211'].max_size, 2) def test_conf_inline(self): @@ -173,10 +173,10 @@ class TestCacheMiddleware(unittest.TestCase): 'memcache_max_connections': '5'}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '6.7.8.9:10') - self.assertEquals(app.memcache._allow_pickle, True) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '6.7.8.9:10') + self.assertEqual(app.memcache._allow_pickle, True) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['6.7.8.9:10'].max_size, 5) def test_conf_extra_no_section(self): @@ -186,10 +186,10 @@ class TestCacheMiddleware(unittest.TestCase): app = memcache.MemcacheMiddleware(FakeApp(), {}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '127.0.0.1:11211') - self.assertEquals(app.memcache._allow_pickle, False) - self.assertEquals(app.memcache._allow_unpickle, False) - self.assertEquals( + self.assertEqual(app.memcache_servers, '127.0.0.1:11211') + self.assertEqual(app.memcache._allow_pickle, False) + self.assertEqual(app.memcache._allow_unpickle, False) + self.assertEqual( app.memcache._client_cache['127.0.0.1:11211'].max_size, 2) def test_conf_extra_no_option(self): @@ -201,10 +201,10 @@ class TestCacheMiddleware(unittest.TestCase): app = memcache.MemcacheMiddleware(FakeApp(), {}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '127.0.0.1:11211') - self.assertEquals(app.memcache._allow_pickle, False) - self.assertEquals(app.memcache._allow_unpickle, False) - self.assertEquals( + self.assertEqual(app.memcache_servers, '127.0.0.1:11211') + self.assertEqual(app.memcache._allow_pickle, False) + self.assertEqual(app.memcache._allow_unpickle, False) + self.assertEqual( app.memcache._client_cache['127.0.0.1:11211'].max_size, 2) def test_conf_inline_other_max_conn(self): @@ -218,10 +218,10 @@ class TestCacheMiddleware(unittest.TestCase): 'max_connections': '5'}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '6.7.8.9:10') - self.assertEquals(app.memcache._allow_pickle, True) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '6.7.8.9:10') + self.assertEqual(app.memcache._allow_pickle, True) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['6.7.8.9:10'].max_size, 5) def test_conf_inline_bad_max_conn(self): @@ -235,10 +235,10 @@ class TestCacheMiddleware(unittest.TestCase): 'max_connections': 'bad42'}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '6.7.8.9:10') - self.assertEquals(app.memcache._allow_pickle, True) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '6.7.8.9:10') + self.assertEqual(app.memcache._allow_pickle, True) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['6.7.8.9:10'].max_size, 4) def test_conf_from_extra_conf(self): @@ -248,10 +248,10 @@ class TestCacheMiddleware(unittest.TestCase): app = memcache.MemcacheMiddleware(FakeApp(), {}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '1.2.3.4:5') - self.assertEquals(app.memcache._allow_pickle, False) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '1.2.3.4:5') + self.assertEqual(app.memcache._allow_pickle, False) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['1.2.3.4:5'].max_size, 4) def test_conf_from_extra_conf_bad_max_conn(self): @@ -262,10 +262,10 @@ class TestCacheMiddleware(unittest.TestCase): app = memcache.MemcacheMiddleware(FakeApp(), {}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '1.2.3.4:5') - self.assertEquals(app.memcache._allow_pickle, False) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '1.2.3.4:5') + self.assertEqual(app.memcache._allow_pickle, False) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['1.2.3.4:5'].max_size, 2) def test_conf_from_inline_and_maxc_from_extra_conf(self): @@ -278,10 +278,10 @@ class TestCacheMiddleware(unittest.TestCase): 'memcache_serialization_support': '0'}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '6.7.8.9:10') - self.assertEquals(app.memcache._allow_pickle, True) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '6.7.8.9:10') + self.assertEqual(app.memcache._allow_pickle, True) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['6.7.8.9:10'].max_size, 4) def test_conf_from_inline_and_sers_from_extra_conf(self): @@ -294,10 +294,10 @@ class TestCacheMiddleware(unittest.TestCase): 'memcache_max_connections': '42'}) finally: memcache.ConfigParser = orig_parser - self.assertEquals(app.memcache_servers, '6.7.8.9:10') - self.assertEquals(app.memcache._allow_pickle, False) - self.assertEquals(app.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(app.memcache_servers, '6.7.8.9:10') + self.assertEqual(app.memcache._allow_pickle, False) + self.assertEqual(app.memcache._allow_unpickle, True) + self.assertEqual( app.memcache._client_cache['6.7.8.9:10'].max_size, 42) def test_filter_factory(self): @@ -305,11 +305,11 @@ class TestCacheMiddleware(unittest.TestCase): memcache_servers='10.10.10.10:10', memcache_serialization_support='1') thefilter = factory('myapp') - self.assertEquals(thefilter.app, 'myapp') - self.assertEquals(thefilter.memcache_servers, '10.10.10.10:10') - self.assertEquals(thefilter.memcache._allow_pickle, False) - self.assertEquals(thefilter.memcache._allow_unpickle, True) - self.assertEquals( + self.assertEqual(thefilter.app, 'myapp') + self.assertEqual(thefilter.memcache_servers, '10.10.10.10:10') + self.assertEqual(thefilter.memcache._allow_pickle, False) + self.assertEqual(thefilter.memcache._allow_unpickle, True) + self.assertEqual( thefilter.memcache._client_cache['10.10.10.10:10'].max_size, 3) @patch_policies diff --git a/test/unit/common/middleware/test_name_check.py b/test/unit/common/middleware/test_name_check.py index eaf28fa864..89be2daf56 100644 --- a/test/unit/common/middleware/test_name_check.py +++ b/test/unit/common/middleware/test_name_check.py @@ -48,7 +48,7 @@ class TestNameCheckMiddleware(unittest.TestCase): path = '/V1.0/' + 'c' * (MAX_LENGTH - 6) resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'} ).get_response(self.test_check) - self.assertEquals(resp.body, 'OK') + self.assertEqual(resp.body, 'OK') def test_invalid_character(self): for c in self.conf['forbidden_chars']: @@ -56,11 +56,11 @@ class TestNameCheckMiddleware(unittest.TestCase): resp = Request.blank( path, environ={'REQUEST_METHOD': 'PUT'}).get_response( self.test_check) - self.assertEquals( + self.assertEqual( resp.body, ("Object/Container/Account name contains forbidden chars " "from %s" % self.conf['forbidden_chars'])) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) def test_maximum_length_from_config(self): # test invalid length @@ -70,29 +70,29 @@ class TestNameCheckMiddleware(unittest.TestCase): path = '/V1.0/a/c' + 'o' * (500 - 8) resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'} ).get_response(self.test_check) - self.assertEquals( + self.assertEqual( resp.body, ("Object/Container/Account name longer than the allowed " "maximum 500")) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) # test valid length path = '/V1.0/a/c' + 'o' * (MAX_LENGTH - 10) resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'} ).get_response(self.test_check) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.body, 'OK') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.body, 'OK') self.test_check = orig_test_check def test_invalid_length(self): path = '/V1.0/' + 'c' * (MAX_LENGTH - 5) resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'} ).get_response(self.test_check) - self.assertEquals( + self.assertEqual( resp.body, ("Object/Container/Account name longer than the allowed maximum %s" % self.conf['maximum_length'])) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) def test_invalid_regexp(self): for s in ['/.', '/..', '/./foo', '/../foo']: @@ -100,12 +100,12 @@ class TestNameCheckMiddleware(unittest.TestCase): resp = Request.blank( path, environ={'REQUEST_METHOD': 'PUT'}).get_response( self.test_check) - self.assertEquals( + self.assertEqual( resp.body, ("Object/Container/Account name contains a forbidden " "substring from regular expression %s" % self.conf['forbidden_regexp'])) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) def test_valid_regexp(self): for s in ['/...', '/.\.', '/foo']: @@ -113,7 +113,7 @@ class TestNameCheckMiddleware(unittest.TestCase): resp = Request.blank( path, environ={'REQUEST_METHOD': 'PUT'}).get_response( self.test_check) - self.assertEquals(resp.body, 'OK') + self.assertEqual(resp.body, 'OK') if __name__ == '__main__': diff --git a/test/unit/common/middleware/test_proxy_logging.py b/test/unit/common/middleware/test_proxy_logging.py index d7d22aaae4..19866cb793 100644 --- a/test/unit/common/middleware/test_proxy_logging.py +++ b/test/unit/common/middleware/test_proxy_logging.py @@ -114,17 +114,17 @@ class TestProxyLogging(unittest.TestCase): def _log_parts(self, app, should_be_empty=False): info_calls = app.access_logger.log_dict['info'] if should_be_empty: - self.assertEquals([], info_calls) + self.assertEqual([], info_calls) else: - self.assertEquals(1, len(info_calls)) + self.assertEqual(1, len(info_calls)) return info_calls[0][0][0].split(' ') def assertTiming(self, exp_metric, app, exp_timing=None): timing_calls = app.access_logger.log_dict['timing'] found = False for timing_call in timing_calls: - self.assertEquals({}, timing_call[1]) - self.assertEquals(2, len(timing_call[0])) + self.assertEqual({}, timing_call[1]) + self.assertEqual(2, len(timing_call[0])) if timing_call[0][0] == exp_metric: found = True if exp_timing is not None: @@ -138,8 +138,8 @@ class TestProxyLogging(unittest.TestCase): timing_calls = app.access_logger.log_dict['timing_since'] found = False for timing_call in timing_calls: - self.assertEquals({}, timing_call[1]) - self.assertEquals(2, len(timing_call[0])) + self.assertEqual({}, timing_call[1]) + self.assertEqual(2, len(timing_call[0])) if timing_call[0][0] == exp_metric: found = True if exp_start is not None: @@ -395,12 +395,12 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'FAKE APP') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'FAKE APP') + self.assertEqual(log_parts[11], str(len(resp_body))) def test_basic_req_second_time(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) @@ -411,7 +411,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) self._log_parts(app, should_be_empty=True) - self.assertEquals(resp_body, 'FAKE APP') + self.assertEqual(resp_body, 'FAKE APP') def test_multi_segment_resp(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp( @@ -422,12 +422,12 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'somechunksof data') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'somechunksof data') + self.assertEqual(log_parts[11], str(len(resp_body))) self.assertUpdateStats([('SOS.GET.200.xfer', len(resp_body))], app) def test_log_headers(self): @@ -476,8 +476,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[11], str(len('FAKE APP'))) - self.assertEquals(log_parts[10], str(len('some stuff'))) + self.assertEqual(log_parts[11], str(len('FAKE APP'))) + self.assertEqual(log_parts[10], str(len('some stuff'))) self.assertUpdateStats([('object.PUT.200.xfer', len('some stuff') + len('FAKE APP')), ('object.policy.0.PUT.200.xfer', @@ -496,8 +496,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[11], str(len('FAKE APP'))) - self.assertEquals(log_parts[10], str(len('some stuff'))) + self.assertEqual(log_parts[11], str(len('FAKE APP'))) + self.assertEqual(log_parts[10], str(len('some stuff'))) self.assertUpdateStats([('object.PUT.200.xfer', len('some stuff') + len('FAKE APP'))], app) @@ -514,8 +514,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[11], str(len('FAKE APP'))) - self.assertEquals(log_parts[10], str(len('some stuff'))) + self.assertEqual(log_parts[11], str(len('FAKE APP'))) + self.assertEqual(log_parts[10], str(len('some stuff'))) self.assertUpdateStats([('object.PUT.200.xfer', len('some stuff') + len('FAKE APP'))], app) @@ -532,8 +532,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[11], str(len('FAKE APP'))) - self.assertEquals(log_parts[10], str(len('some stuff\n'))) + self.assertEqual(log_parts[11], str(len('FAKE APP'))) + self.assertEqual(log_parts[10], str(len('some stuff\n'))) self.assertUpdateStats([('container.POST.200.xfer', len('some stuff\n') + len('FAKE APP'))], app) @@ -547,7 +547,7 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(unquote(log_parts[4]), '/?x=3') + self.assertEqual(unquote(log_parts[4]), '/?x=3') def test_client_logging(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) @@ -558,8 +558,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[0], '1.2.3.4') # client ip - self.assertEquals(log_parts[1], '1.2.3.4') # remote addr + self.assertEqual(log_parts[0], '1.2.3.4') # client ip + self.assertEqual(log_parts[1], '1.2.3.4') # remote addr def test_iterator_closing(self): @@ -593,8 +593,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[0], '4.5.6.7') # client ip - self.assertEquals(log_parts[1], '1.2.3.4') # remote addr + self.assertEqual(log_parts[0], '4.5.6.7') # client ip + self.assertEqual(log_parts[1], '1.2.3.4') # remote addr app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) app.access_logger = FakeLogger() @@ -606,8 +606,8 @@ class TestProxyLogging(unittest.TestCase): # exhaust generator [x for x in resp] log_parts = self._log_parts(app) - self.assertEquals(log_parts[0], '4.5.6.7') # client ip - self.assertEquals(log_parts[1], '1.2.3.4') # remote addr + self.assertEqual(log_parts[0], '4.5.6.7') # client ip + self.assertEqual(log_parts[1], '1.2.3.4') # remote addr def test_facility(self): app = proxy_logging.ProxyLoggingMiddleware( @@ -615,7 +615,7 @@ class TestProxyLogging(unittest.TestCase): {'log_headers': 'yes', 'access_log_facility': 'LOG_LOCAL7'}) handler = get_logger.handler4logger[app.access_logger.logger] - self.assertEquals(SysLogHandler.LOG_LOCAL7, handler.facility) + self.assertEqual(SysLogHandler.LOG_LOCAL7, handler.facility) def test_filter(self): factory = proxy_logging.filter_factory({}) @@ -632,8 +632,8 @@ class TestProxyLogging(unittest.TestCase): next(resp) resp.close() # raise a GeneratorExit in middleware app_iter loop log_parts = self._log_parts(app) - self.assertEquals(log_parts[6], '499') - self.assertEquals(log_parts[11], '4') # write length + self.assertEqual(log_parts[6], '499') + self.assertEqual(log_parts[11], '4') # write length def test_disconnect_on_readline(self): app = proxy_logging.ProxyLoggingMiddleware(FakeAppReadline(), {}) @@ -647,8 +647,8 @@ class TestProxyLogging(unittest.TestCase): except IOError: pass log_parts = self._log_parts(app) - self.assertEquals(log_parts[6], '499') - self.assertEquals(log_parts[10], '-') # read length + self.assertEqual(log_parts[6], '499') + self.assertEqual(log_parts[10], '-') # read length def test_disconnect_on_read(self): app = proxy_logging.ProxyLoggingMiddleware( @@ -663,8 +663,8 @@ class TestProxyLogging(unittest.TestCase): except IOError: pass log_parts = self._log_parts(app) - self.assertEquals(log_parts[6], '499') - self.assertEquals(log_parts[10], '-') # read length + self.assertEqual(log_parts[6], '499') + self.assertEqual(log_parts[10], '-') # read length def test_app_exception(self): app = proxy_logging.ProxyLoggingMiddleware( @@ -676,8 +676,8 @@ class TestProxyLogging(unittest.TestCase): except Exception: pass log_parts = self._log_parts(app) - self.assertEquals(log_parts[6], '500') - self.assertEquals(log_parts[10], '-') # read length + self.assertEqual(log_parts[6], '500') + self.assertEqual(log_parts[10], '-') # read length def test_no_content_length_no_transfer_encoding_with_list_body(self): app = proxy_logging.ProxyLoggingMiddleware( @@ -690,12 +690,12 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'line1\nline2\n') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'line1\nline2\n') + self.assertEqual(log_parts[11], str(len(resp_body))) def test_no_content_length_no_transfer_encoding_with_empty_strings(self): app = proxy_logging.ProxyLoggingMiddleware( @@ -708,12 +708,12 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, '') - self.assertEquals(log_parts[11], '-') + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, '') + self.assertEqual(log_parts[11], '-') def test_no_content_length_no_transfer_encoding_with_generator(self): @@ -733,28 +733,28 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'abc') - self.assertEquals(log_parts[11], '3') + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'abc') + self.assertEqual(log_parts[11], '3') def test_req_path_info_popping(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) app.access_logger = FakeLogger() req = Request.blank('/v1/something', environ={'REQUEST_METHOD': 'GET'}) req.path_info_pop() - self.assertEquals(req.environ['PATH_INFO'], '/something') + self.assertEqual(req.environ['PATH_INFO'], '/something') resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/v1/something') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'FAKE APP') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/v1/something') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'FAKE APP') + self.assertEqual(log_parts[11], str(len(resp_body))) def test_ipv6(self): ipv6addr = '2001:db8:85a3:8d3:1319:8a2e:370:7348' @@ -765,14 +765,14 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[0], ipv6addr) - self.assertEquals(log_parts[1], ipv6addr) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'FAKE APP') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[0], ipv6addr) + self.assertEqual(log_parts[1], ipv6addr) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'FAKE APP') + self.assertEqual(log_parts[11], str(len(resp_body))) def test_log_info_none(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) @@ -780,7 +780,7 @@ class TestProxyLogging(unittest.TestCase): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) list(app(req.environ, start_response)) log_parts = self._log_parts(app) - self.assertEquals(log_parts[17], '-') + self.assertEqual(log_parts[17], '-') app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) app.access_logger = FakeLogger() @@ -788,7 +788,7 @@ class TestProxyLogging(unittest.TestCase): req.environ['swift.log_info'] = [] list(app(req.environ, start_response)) log_parts = self._log_parts(app) - self.assertEquals(log_parts[17], '-') + self.assertEqual(log_parts[17], '-') def test_log_info_single(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) @@ -797,7 +797,7 @@ class TestProxyLogging(unittest.TestCase): req.environ['swift.log_info'] = ['one'] list(app(req.environ, start_response)) log_parts = self._log_parts(app) - self.assertEquals(log_parts[17], 'one') + self.assertEqual(log_parts[17], 'one') def test_log_info_multiple(self): app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) @@ -806,7 +806,7 @@ class TestProxyLogging(unittest.TestCase): req.environ['swift.log_info'] = ['one', 'and two'] list(app(req.environ, start_response)) log_parts = self._log_parts(app) - self.assertEquals(log_parts[17], 'one%2Cand%20two') + self.assertEqual(log_parts[17], 'one%2Cand%20two') def test_log_auth_token(self): auth_token = 'b05bf940-0464-4c0e-8c70-87717d2d73e8' @@ -819,7 +819,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], '-') + self.assertEqual(log_parts[9], '-') # Has x-auth-token header app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {}) app.access_logger = FakeLogger() @@ -828,7 +828,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], 'b05bf940-0464-4c...') + self.assertEqual(log_parts[9], 'b05bf940-0464-4c...') # Truncate to first 8 characters app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), { @@ -838,7 +838,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], '-') + self.assertEqual(log_parts[9], '-') app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), { 'reveal_sensitive_prefix': '8'}) app.access_logger = FakeLogger() @@ -847,7 +847,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], 'b05bf940...') + self.assertEqual(log_parts[9], 'b05bf940...') # Token length and reveal_sensitive_prefix are same (no truncate) app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), { @@ -858,7 +858,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], auth_token) + self.assertEqual(log_parts[9], auth_token) # No effective limit on auth token app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), { @@ -869,7 +869,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], auth_token) + self.assertEqual(log_parts[9], auth_token) # Don't log x-auth-token app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), { @@ -879,7 +879,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], '-') + self.assertEqual(log_parts[9], '-') app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), { 'reveal_sensitive_prefix': '0'}) app.access_logger = FakeLogger() @@ -888,7 +888,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[9], '...') + self.assertEqual(log_parts[9], '...') # Avoids pyflakes error, "local variable 'resp_body' is assigned to # but never used @@ -904,29 +904,29 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) resp_body = ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(len(log_parts), 21) - self.assertEquals(log_parts[0], '-') - self.assertEquals(log_parts[1], '-') - self.assertEquals(log_parts[2], '26/Apr/1970/17/46/41') - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(log_parts[7], '-') - self.assertEquals(log_parts[8], '-') - self.assertEquals(log_parts[9], '-') - self.assertEquals(log_parts[10], '-') - self.assertEquals(resp_body, 'FAKE APP') - self.assertEquals(log_parts[11], str(len(resp_body))) - self.assertEquals(log_parts[12], '-') - self.assertEquals(log_parts[13], '-') - self.assertEquals(log_parts[14], '-') - self.assertEquals(log_parts[15], '1.0000') - self.assertEquals(log_parts[16], '-') - self.assertEquals(log_parts[17], '-') - self.assertEquals(log_parts[18], '10000000.000000000') - self.assertEquals(log_parts[19], '10000001.000000000') - self.assertEquals(log_parts[20], '-') + self.assertEqual(len(log_parts), 21) + self.assertEqual(log_parts[0], '-') + self.assertEqual(log_parts[1], '-') + self.assertEqual(log_parts[2], '26/Apr/1970/17/46/41') + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(log_parts[7], '-') + self.assertEqual(log_parts[8], '-') + self.assertEqual(log_parts[9], '-') + self.assertEqual(log_parts[10], '-') + self.assertEqual(resp_body, 'FAKE APP') + self.assertEqual(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[12], '-') + self.assertEqual(log_parts[13], '-') + self.assertEqual(log_parts[14], '-') + self.assertEqual(log_parts[15], '1.0000') + self.assertEqual(log_parts[16], '-') + self.assertEqual(log_parts[17], '-') + self.assertEqual(log_parts[18], '10000000.000000000') + self.assertEqual(log_parts[19], '10000001.000000000') + self.assertEqual(log_parts[20], '-') def test_dual_logging_middlewares(self): # Since no internal request is being made, outer most proxy logging @@ -943,12 +943,12 @@ class TestProxyLogging(unittest.TestCase): resp_body = ''.join(resp) self._log_parts(log0, should_be_empty=True) log_parts = self._log_parts(log1) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'FAKE APP') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'FAKE APP') + self.assertEqual(log_parts[11], str(len(resp_body))) def test_dual_logging_middlewares_w_inner(self): @@ -994,20 +994,20 @@ class TestProxyLogging(unittest.TestCase): # Inner most logger should have logged the app's response log_parts = self._log_parts(log0) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(log_parts[11], str(len('FAKE APP'))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(log_parts[11], str(len('FAKE APP'))) # Outer most logger should have logged the other middleware's response log_parts = self._log_parts(log1) - self.assertEquals(log_parts[3], 'GET') - self.assertEquals(log_parts[4], '/') - self.assertEquals(log_parts[5], 'HTTP/1.0') - self.assertEquals(log_parts[6], '200') - self.assertEquals(resp_body, 'FAKE MIDDLEWARE') - self.assertEquals(log_parts[11], str(len(resp_body))) + self.assertEqual(log_parts[3], 'GET') + self.assertEqual(log_parts[4], '/') + self.assertEqual(log_parts[5], 'HTTP/1.0') + self.assertEqual(log_parts[6], '200') + self.assertEqual(resp_body, 'FAKE MIDDLEWARE') + self.assertEqual(log_parts[11], str(len(resp_body))) def test_policy_index(self): # Policy index can be specified by X-Backend-Storage-Policy-Index @@ -1018,7 +1018,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[20], '1') + self.assertEqual(log_parts[20], '1') # Policy index can be specified by X-Backend-Storage-Policy-Index # in the response header for container API @@ -1039,7 +1039,7 @@ class TestProxyLogging(unittest.TestCase): resp = app(req.environ, start_response) ''.join(resp) log_parts = self._log_parts(app) - self.assertEquals(log_parts[20], '1') + self.assertEqual(log_parts[20], '1') if __name__ == '__main__': diff --git a/test/unit/common/middleware/test_quotas.py b/test/unit/common/middleware/test_quotas.py index 85211257de..b71b78ed83 100644 --- a/test/unit/common/middleware/test_quotas.py +++ b/test/unit/common/middleware/test_quotas.py @@ -62,18 +62,18 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': {'key': 'value'}}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_handled(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_no_quotas(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -82,7 +82,7 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': FakeCache({}), 'CONTENT_LENGTH': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_exceed_bytes_quota(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -92,8 +92,8 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_bytes_quota_copy_from(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -105,8 +105,8 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_bytes_quota_copy_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -118,8 +118,8 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_not_exceed_bytes_quota(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -129,7 +129,7 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_exceed_bytes_quota_copy_from(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -140,7 +140,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_exceed_bytes_quota_copy_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -151,7 +151,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_bytes_quota_copy_from_no_src(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -162,7 +162,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o3'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_bytes_quota_copy_from_bad_src(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -172,7 +172,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': 'bad_path'}) res = req.get_response(app) - self.assertEquals(res.status_int, 412) + self.assertEqual(res.status_int, 412) def test_bytes_quota_copy_verb_no_src(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -183,7 +183,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_exceed_counts_quota(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -193,8 +193,8 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_counts_quota_copy_from(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -205,8 +205,8 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_counts_quota_copy_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -216,8 +216,8 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_counts_quota_copy_cross_account_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -232,8 +232,8 @@ class TestContainerQuotas(unittest.TestCase): headers={'Destination': '/c/o', 'Destination-Account': 'a2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_exceed_counts_quota_copy_cross_account_PUT_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -248,8 +248,8 @@ class TestContainerQuotas(unittest.TestCase): headers={'X-Copy-From': '/c2/o2', 'X-Copy-From-Account': 'a'}) res = req.get_response(app) - self.assertEquals(res.status_int, 413) - self.assertEquals(res.body, 'Upload exceeds quota.') + self.assertEqual(res.status_int, 413) + self.assertEqual(res.body, 'Upload exceeds quota.') def test_not_exceed_counts_quota(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -259,7 +259,7 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_exceed_counts_quota_copy_from(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -269,7 +269,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_not_exceed_counts_quota_copy_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -279,7 +279,7 @@ class TestContainerQuotas(unittest.TestCase): 'swift.cache': cache}, headers={'Destination': '/c/o'}) res = req.get_response(app) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_invalid_quotas(self): req = Request.blank( @@ -288,7 +288,7 @@ class TestContainerQuotas(unittest.TestCase): 'HTTP_X_CONTAINER_META_QUOTA_BYTES': 'abc'}) res = req.get_response( container_quotas.ContainerQuotaMiddleware(FakeApp(), {})) - self.assertEquals(res.status_int, 400) + self.assertEqual(res.status_int, 400) req = Request.blank( '/v1/a/c', @@ -296,7 +296,7 @@ class TestContainerQuotas(unittest.TestCase): 'HTTP_X_CONTAINER_META_QUOTA_COUNT': 'abc'}) res = req.get_response( container_quotas.ContainerQuotaMiddleware(FakeApp(), {})) - self.assertEquals(res.status_int, 400) + self.assertEqual(res.status_int, 400) def test_valid_quotas(self): req = Request.blank( @@ -305,7 +305,7 @@ class TestContainerQuotas(unittest.TestCase): 'HTTP_X_CONTAINER_META_QUOTA_BYTES': '123'}) res = req.get_response( container_quotas.ContainerQuotaMiddleware(FakeApp(), {})) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) req = Request.blank( '/v1/a/c', @@ -313,7 +313,7 @@ class TestContainerQuotas(unittest.TestCase): 'HTTP_X_CONTAINER_META_QUOTA_COUNT': '123'}) res = req.get_response( container_quotas.ContainerQuotaMiddleware(FakeApp(), {})) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_delete_quotas(self): req = Request.blank( @@ -322,7 +322,7 @@ class TestContainerQuotas(unittest.TestCase): 'HTTP_X_CONTAINER_META_QUOTA_BYTES': None}) res = req.get_response( container_quotas.ContainerQuotaMiddleware(FakeApp(), {})) - self.assertEquals(res.status_int, 200) + self.assertEqual(res.status_int, 200) def test_missing_container(self): app = container_quotas.ContainerQuotaMiddleware(FakeMissingApp(), {}) @@ -332,7 +332,7 @@ class TestContainerQuotas(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) res = req.get_response(app) - self.assertEquals(res.status_int, 404) + self.assertEqual(res.status_int, 404) def test_auth_fail(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -344,7 +344,7 @@ class TestContainerQuotas(unittest.TestCase): 'CONTENT_LENGTH': '100', 'swift.authorize': lambda *args: HTTPUnauthorized()}) res = req.get_response(app) - self.assertEquals(res.status_int, 401) + self.assertEqual(res.status_int, 401) if __name__ == '__main__': unittest.main() diff --git a/test/unit/common/middleware/test_ratelimit.py b/test/unit/common/middleware/test_ratelimit.py index eb9f5e41ac..2d865f5b50 100644 --- a/test/unit/common/middleware/test_ratelimit.py +++ b/test/unit/common/middleware/test_ratelimit.py @@ -159,7 +159,7 @@ class TestRateLimit(unittest.TestCase): # Allow for one second of variation in the total time. time_diff = abs(total_time - (end - begin)) if check_time: - self.assertEquals(round(total_time, 1), round(time_ticker, 1)) + self.assertEqual(round(total_time, 1), round(time_ticker, 1)) return time_diff def test_get_maxrate(self): @@ -168,15 +168,15 @@ class TestRateLimit(unittest.TestCase): 'container_ratelimit_75': 30} test_ratelimit = ratelimit.filter_factory(conf_dict)(FakeApp()) test_ratelimit.logger = FakeLogger() - self.assertEquals(ratelimit.get_maxrate( + self.assertEqual(ratelimit.get_maxrate( test_ratelimit.container_ratelimits, 0), None) - self.assertEquals(ratelimit.get_maxrate( + self.assertEqual(ratelimit.get_maxrate( test_ratelimit.container_ratelimits, 5), None) - self.assertEquals(ratelimit.get_maxrate( + self.assertEqual(ratelimit.get_maxrate( test_ratelimit.container_ratelimits, 10), 200) - self.assertEquals(ratelimit.get_maxrate( + self.assertEqual(ratelimit.get_maxrate( test_ratelimit.container_ratelimits, 60), 72) - self.assertEquals(ratelimit.get_maxrate( + self.assertEqual(ratelimit.get_maxrate( test_ratelimit.container_ratelimits, 160), 30) def test_get_ratelimitable_key_tuples(self): @@ -193,35 +193,35 @@ class TestRateLimit(unittest.TestCase): with mock.patch('swift.common.middleware.ratelimit.get_account_info', lambda *args, **kwargs: {}): req.method = 'DELETE' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', None, None)), 0) req.method = 'PUT' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', None)), 1) req.method = 'DELETE' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', None)), 1) req.method = 'GET' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', 'o')), 0) req.method = 'PUT' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', 'o')), 1) req.method = 'PUT' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', None, global_ratelimit=10)), 2) - self.assertEquals(the_app.get_ratelimitable_key_tuples( + self.assertEqual(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', None, global_ratelimit=10)[1], ('ratelimit/global-write/a', 10)) req.method = 'PUT' - self.assertEquals(len(the_app.get_ratelimitable_key_tuples( + self.assertEqual(len(the_app.get_ratelimitable_key_tuples( req, 'a', 'c', None, global_ratelimit='notafloat')), 1) def test_memcached_container_info_dict(self): mdict = headers_to_container_info({'x-container-object-count': '45'}) - self.assertEquals(mdict['object_count'], '45') + self.assertEqual(mdict['object_count'], '45') def test_ratelimit_old_memcache_format(self): current_rate = 13 @@ -238,7 +238,7 @@ class TestRateLimit(unittest.TestCase): with mock.patch('swift.common.middleware.ratelimit.get_account_info', lambda *args, **kwargs: {}): tuples = the_app.get_ratelimitable_key_tuples(req, 'a', 'c', 'o') - self.assertEquals(tuples, [('ratelimit/a/c', 200.0)]) + self.assertEqual(tuples, [('ratelimit/a/c', 200.0)]) def test_account_ratelimit(self): current_rate = 5 @@ -261,7 +261,7 @@ class TestRateLimit(unittest.TestCase): begin = time.time() self._run(make_app_call, num_calls, current_rate, check_time=bool(exp_time)) - self.assertEquals(round(time.time() - begin, 1), exp_time) + self.assertEqual(round(time.time() - begin, 1), exp_time) self._reset_time() def test_ratelimit_set_incr(self): @@ -280,7 +280,7 @@ class TestRateLimit(unittest.TestCase): with mock.patch('swift.common.middleware.ratelimit.get_account_info', lambda *args, **kwargs: {}): self._run(make_app_call, num_calls, current_rate, check_time=False) - self.assertEquals(round(time.time() - begin, 1), 9.8) + self.assertEqual(round(time.time() - begin, 1), 9.8) def test_ratelimit_old_white_black_list(self): global time_ticker @@ -339,8 +339,8 @@ class TestRateLimit(unittest.TestCase): the_498s = [ t for t in threads if ''.join(t.result).startswith('Slow down')] - self.assertEquals(len(the_498s), 0) - self.assertEquals(time_ticker, 0) + self.assertEqual(len(the_498s), 0) + self.assertEqual(time_ticker, 0) def test_ratelimit_blacklist(self): global time_ticker @@ -382,8 +382,8 @@ class TestRateLimit(unittest.TestCase): the_497s = [ t for t in threads if ''.join(t.result).startswith('Your account')] - self.assertEquals(len(the_497s), 5) - self.assertEquals(time_ticker, 0) + self.assertEqual(len(the_497s), 5) + self.assertEqual(time_ticker, 0) def test_ratelimit_max_rate_double(self): global time_ticker @@ -408,13 +408,13 @@ class TestRateLimit(unittest.TestCase): r = self.test_ratelimit(req.environ, start_response) mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], 'Slow down') + self.assertEqual(r[0], 'Slow down') mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], 'Slow down') + self.assertEqual(r[0], 'Slow down') mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], '204 No Content') + self.assertEqual(r[0], '204 No Content') def test_ratelimit_max_rate_double_container(self): global time_ticker @@ -442,13 +442,13 @@ class TestRateLimit(unittest.TestCase): r = self.test_ratelimit(req.environ, start_response) mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], 'Slow down') + self.assertEqual(r[0], 'Slow down') mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], 'Slow down') + self.assertEqual(r[0], 'Slow down') mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], '204 No Content') + self.assertEqual(r[0], '204 No Content') def test_ratelimit_max_rate_double_container_listing(self): global time_ticker @@ -476,17 +476,17 @@ class TestRateLimit(unittest.TestCase): r = self.test_ratelimit(req.environ, start_response) mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], 'Slow down') + self.assertEqual(r[0], 'Slow down') mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], 'Slow down') + self.assertEqual(r[0], 'Slow down') mock_sleep(.1) r = self.test_ratelimit(req.environ, start_response) - self.assertEquals(r[0], '204 No Content') + self.assertEqual(r[0], '204 No Content') mc = self.test_ratelimit.memcache_client try: self.test_ratelimit.memcache_client = None - self.assertEquals( + self.assertEqual( self.test_ratelimit.handle_ratelimit(req, 'n', 'c', None), None) finally: @@ -529,7 +529,7 @@ class TestRateLimit(unittest.TestCase): thread.join() time_took = time.time() - begin - self.assertEquals(1.5, round(time_took, 1)) + self.assertEqual(1.5, round(time_took, 1)) def test_call_invalid_path(self): env = {'REQUEST_METHOD': 'GET', @@ -563,7 +563,7 @@ class TestRateLimit(unittest.TestCase): begin = time.time() self._run(make_app_call, num_calls, current_rate, check_time=False) time_took = time.time() - begin - self.assertEquals(round(time_took, 1), 0) # no memcache, no limiting + self.assertEqual(round(time_took, 1), 0) # no memcache, no limiting def test_restarting_memcache(self): current_rate = 2 @@ -582,7 +582,7 @@ class TestRateLimit(unittest.TestCase): lambda *args, **kwargs: {}): self._run(make_app_call, num_calls, current_rate, check_time=False) time_took = time.time() - begin - self.assertEquals(round(time_took, 1), 0) # no memcache, no limit + self.assertEqual(round(time_took, 1), 0) # no memcache, no limit class TestSwiftInfo(unittest.TestCase): diff --git a/test/unit/common/middleware/test_recon.py b/test/unit/common/middleware/test_recon.py index 1dedec688c..049a60c2c8 100644 --- a/test/unit/common/middleware/test_recon.py +++ b/test/unit/common/middleware/test_recon.py @@ -310,8 +310,8 @@ class TestReconSuccess(TestCase): # object-{1,2}.ring.gz should both appear as they are present on disk # and were configured as policies. app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir}) - self.assertEquals(sorted(app.get_ring_md5().items()), - sorted(expt_out.items())) + self.assertEqual(sorted(app.get_ring_md5().items()), + sorted(expt_out.items())) def test_get_ring_md5_ioerror_produces_none_hash(self): # Ring files that are present but produce an IOError on read should @@ -326,8 +326,8 @@ class TestReconSuccess(TestCase): '%s/container.ring.gz' % self.tempdir: None, '%s/object.ring.gz' % self.tempdir: None} ringmd5 = self.app.get_ring_md5(openr=fake_open) - self.assertEquals(sorted(ringmd5.items()), - sorted(expt_out.items())) + self.assertEqual(sorted(ringmd5.items()), + sorted(expt_out.items())) def test_get_ring_md5_failed_ring_hash_recovers_without_restart(self): # Ring files that are present but produce an IOError on read will @@ -341,8 +341,8 @@ class TestReconSuccess(TestCase): '%s/container.ring.gz' % self.tempdir: None, '%s/object.ring.gz' % self.tempdir: None} ringmd5 = self.app.get_ring_md5(openr=fake_open) - self.assertEquals(sorted(ringmd5.items()), - sorted(expt_out.items())) + self.assertEqual(sorted(ringmd5.items()), + sorted(expt_out.items())) # If we fix a ring and it can be read again, its hash should then # appear using the same app instance @@ -356,8 +356,8 @@ class TestReconSuccess(TestCase): '%s/object.ring.gz' % self.tempdir: 'da02bfbd0bf1e7d56faea15b6fe5ab1e'} ringmd5 = self.app.get_ring_md5(openr=fake_open_objonly) - self.assertEquals(sorted(ringmd5.items()), - sorted(expt_out.items())) + self.assertEqual(sorted(ringmd5.items()), + sorted(expt_out.items())) @patch_policies([ StoragePolicy(0, 'stagecoach'), @@ -382,8 +382,8 @@ class TestReconSuccess(TestCase): # object-3502.ring.gz should not appear as it's configured but not # present. app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir}) - self.assertEquals(sorted(app.get_ring_md5().items()), - sorted(expt_out.items())) + self.assertEqual(sorted(app.get_ring_md5().items()), + sorted(expt_out.items())) # Simulate the configured policy's missing ringfile being moved into # place during runtime @@ -398,8 +398,8 @@ class TestReconSuccess(TestCase): # We should now see it in the ringmd5 response, without a restart # (using the same app instance) - self.assertEquals(sorted(app.get_ring_md5().items()), - sorted(expt_out.items())) + self.assertEqual(sorted(app.get_ring_md5().items()), + sorted(expt_out.items())) @patch_policies([ StoragePolicy(0, 'stagecoach', is_default=True), @@ -423,8 +423,8 @@ class TestReconSuccess(TestCase): # object-2305.ring.gz should not appear as it's configured but not # present. app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir}) - self.assertEquals(sorted(app.get_ring_md5().items()), - sorted(expt_out.items())) + self.assertEqual(sorted(app.get_ring_md5().items()), + sorted(expt_out.items())) @patch_policies([ StoragePolicy(0, 'zero', is_default=True), @@ -443,17 +443,17 @@ class TestReconSuccess(TestCase): # object-{1,2}.ring.gz should not appear as they are present on disk # but were not configured as policies. app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir}) - self.assertEquals(sorted(app.get_ring_md5().items()), - sorted(expt_out.items())) + self.assertEqual(sorted(app.get_ring_md5().items()), + sorted(expt_out.items())) def test_from_recon_cache(self): oart = OpenAndReadTester(['{"notneeded": 5, "testkey1": "canhazio"}']) self.app._from_recon_cache = self.real_from_cache rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'], 'test.cache', openr=oart.open) - self.assertEquals(oart.read_calls, [((), {})]) - self.assertEquals(oart.open_calls, [(('test.cache', 'r'), {})]) - self.assertEquals(rv, {'notpresentkey': None, 'testkey1': 'canhazio'}) + self.assertEqual(oart.read_calls, [((), {})]) + self.assertEqual(oart.open_calls, [(('test.cache', 'r'), {})]) + self.assertEqual(rv, {'notpresentkey': None, 'testkey1': 'canhazio'}) self.app._from_recon_cache = self.fakecache.fake_from_recon_cache def test_from_recon_cache_ioerror(self): @@ -461,7 +461,7 @@ class TestReconSuccess(TestCase): self.app._from_recon_cache = self.real_from_cache rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'], 'test.cache', openr=oart) - self.assertEquals(rv, {'notpresentkey': None, 'testkey1': None}) + self.assertEqual(rv, {'notpresentkey': None, 'testkey1': None}) self.app._from_recon_cache = self.fakecache.fake_from_recon_cache def test_from_recon_cache_valueerror(self): @@ -469,7 +469,7 @@ class TestReconSuccess(TestCase): self.app._from_recon_cache = self.real_from_cache rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'], 'test.cache', openr=oart) - self.assertEquals(rv, {'notpresentkey': None, 'testkey1': None}) + self.assertEqual(rv, {'notpresentkey': None, 'testkey1': None}) self.app._from_recon_cache = self.fakecache.fake_from_recon_cache def test_from_recon_cache_exception(self): @@ -477,7 +477,7 @@ class TestReconSuccess(TestCase): self.app._from_recon_cache = self.real_from_cache rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'], 'test.cache', openr=oart) - self.assertEquals(rv, {'notpresentkey': None, 'testkey1': None}) + self.assertEqual(rv, {'notpresentkey': None, 'testkey1': None}) self.app._from_recon_cache = self.fakecache.fake_from_recon_cache def test_get_mounted(self): @@ -525,17 +525,17 @@ class TestReconSuccess(TestCase): {'device': 'none', 'path': '/proc/fs/vmblock/mountPoint'}] oart = OpenAndReadTester(mounts_content) rv = self.app.get_mounted(openr=oart.open) - self.assertEquals(oart.open_calls, [(('/proc/mounts', 'r'), {})]) - self.assertEquals(rv, mounted_resp) + self.assertEqual(oart.open_calls, [(('/proc/mounts', 'r'), {})]) + self.assertEqual(rv, mounted_resp) def test_get_load(self): oart = OpenAndReadTester(['0.03 0.03 0.00 1/220 16306']) rv = self.app.get_load(openr=oart.open) - self.assertEquals(oart.read_calls, [((), {})]) - self.assertEquals(oart.open_calls, [(('/proc/loadavg', 'r'), {})]) - self.assertEquals(rv, {'5m': 0.029999999999999999, '15m': 0.0, - 'processes': 16306, 'tasks': '1/220', - '1m': 0.029999999999999999}) + self.assertEqual(oart.read_calls, [((), {})]) + self.assertEqual(oart.open_calls, [(('/proc/loadavg', 'r'), {})]) + self.assertEqual(rv, {'5m': 0.029999999999999999, '15m': 0.0, + 'processes': 16306, 'tasks': '1/220', + '1m': 0.029999999999999999}) def test_get_mem(self): meminfo_content = ['MemTotal: 505840 kB', @@ -623,17 +623,17 @@ class TestReconSuccess(TestCase): 'Dirty': '104 kB'} oart = OpenAndReadTester(meminfo_content) rv = self.app.get_mem(openr=oart.open) - self.assertEquals(oart.open_calls, [(('/proc/meminfo', 'r'), {})]) - self.assertEquals(rv, meminfo_resp) + self.assertEqual(oart.open_calls, [(('/proc/meminfo', 'r'), {})]) + self.assertEqual(rv, meminfo_resp) def test_get_async_info(self): from_cache_response = {'async_pending': 5} self.fakecache.fakeout = from_cache_response rv = self.app.get_async_info() - self.assertEquals(self.fakecache.fakeout_calls, - [((['async_pending'], - '/var/cache/swift/object.recon'), {})]) - self.assertEquals(rv, {'async_pending': 5}) + self.assertEqual(self.fakecache.fakeout_calls, + [((['async_pending'], + '/var/cache/swift/object.recon'), {})]) + self.assertEqual(rv, {'async_pending': 5}) def test_get_replication_info_account(self): from_cache_response = { @@ -652,11 +652,11 @@ class TestReconSuccess(TestCase): "replication_last": 1357969645.25} self.fakecache.fakeout = from_cache_response rv = self.app.get_replication_info('account') - self.assertEquals(self.fakecache.fakeout_calls, - [((['replication_time', 'replication_stats', - 'replication_last'], - '/var/cache/swift/account.recon'), {})]) - self.assertEquals(rv, { + self.assertEqual(self.fakecache.fakeout_calls, + [((['replication_time', 'replication_stats', + 'replication_last'], + '/var/cache/swift/account.recon'), {})]) + self.assertEqual(rv, { "replication_stats": { "attempted": 1, "diff": 0, "diff_capped": 0, "empty": 0, @@ -689,11 +689,11 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_replication_info('container') - self.assertEquals(self.fakecache.fakeout_calls, - [((['replication_time', 'replication_stats', - 'replication_last'], - '/var/cache/swift/container.recon'), {})]) - self.assertEquals(rv, { + self.assertEqual(self.fakecache.fakeout_calls, + [((['replication_time', 'replication_stats', + 'replication_last'], + '/var/cache/swift/container.recon'), {})]) + self.assertEqual(rv, { "replication_time": 200.0, "replication_stats": { "attempted": 179, "diff": 0, @@ -725,12 +725,12 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_replication_info('object') - self.assertEquals(self.fakecache.fakeout_calls, - [((['replication_time', 'replication_stats', - 'replication_last', 'object_replication_time', - 'object_replication_last'], - '/var/cache/swift/object.recon'), {})]) - self.assertEquals(rv, { + self.assertEqual(self.fakecache.fakeout_calls, + [((['replication_time', 'replication_stats', + 'replication_last', 'object_replication_time', + 'object_replication_last'], + '/var/cache/swift/object.recon'), {})]) + self.assertEqual(rv, { "replication_time": 0.2615511417388916, "replication_stats": { "attempted": 179, @@ -749,20 +749,20 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_updater_info('container') - self.assertEquals(self.fakecache.fakeout_calls, - [((['container_updater_sweep'], - '/var/cache/swift/container.recon'), {})]) - self.assertEquals(rv, {"container_updater_sweep": 18.476239919662476}) + self.assertEqual(self.fakecache.fakeout_calls, + [((['container_updater_sweep'], + '/var/cache/swift/container.recon'), {})]) + self.assertEqual(rv, {"container_updater_sweep": 18.476239919662476}) def test_get_updater_info_object(self): from_cache_response = {"object_updater_sweep": 0.79848217964172363} self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_updater_info('object') - self.assertEquals(self.fakecache.fakeout_calls, - [((['object_updater_sweep'], - '/var/cache/swift/object.recon'), {})]) - self.assertEquals(rv, {"object_updater_sweep": 0.79848217964172363}) + self.assertEqual(self.fakecache.fakeout_calls, + [((['object_updater_sweep'], + '/var/cache/swift/object.recon'), {})]) + self.assertEqual(rv, {"object_updater_sweep": 0.79848217964172363}) def test_get_expirer_info_object(self): from_cache_response = {'object_expiration_pass': 0.79848217964172363, @@ -770,10 +770,10 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_expirer_info('object') - self.assertEquals(self.fakecache.fakeout_calls, - [((['object_expiration_pass', 'expired_last_pass'], - '/var/cache/swift/object.recon'), {})]) - self.assertEquals(rv, from_cache_response) + self.assertEqual(self.fakecache.fakeout_calls, + [((['object_expiration_pass', 'expired_last_pass'], + '/var/cache/swift/object.recon'), {})]) + self.assertEqual(rv, from_cache_response) def test_get_auditor_info_account(self): from_cache_response = {"account_auditor_pass_completed": 0.24, @@ -783,16 +783,16 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_auditor_info('account') - self.assertEquals(self.fakecache.fakeout_calls, - [((['account_audits_passed', - 'account_auditor_pass_completed', - 'account_audits_since', - 'account_audits_failed'], - '/var/cache/swift/account.recon'), {})]) - self.assertEquals(rv, {"account_auditor_pass_completed": 0.24, - "account_audits_failed": 0, - "account_audits_passed": 6, - "account_audits_since": "1333145374.1373529"}) + self.assertEqual(self.fakecache.fakeout_calls, + [((['account_audits_passed', + 'account_auditor_pass_completed', + 'account_audits_since', + 'account_audits_failed'], + '/var/cache/swift/account.recon'), {})]) + self.assertEqual(rv, {"account_auditor_pass_completed": 0.24, + "account_audits_failed": 0, + "account_audits_passed": 6, + "account_audits_since": "1333145374.1373529"}) def test_get_auditor_info_container(self): from_cache_response = {"container_auditor_pass_completed": 0.24, @@ -802,16 +802,16 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_auditor_info('container') - self.assertEquals(self.fakecache.fakeout_calls, - [((['container_audits_passed', - 'container_auditor_pass_completed', - 'container_audits_since', - 'container_audits_failed'], - '/var/cache/swift/container.recon'), {})]) - self.assertEquals(rv, {"container_auditor_pass_completed": 0.24, - "container_audits_failed": 0, - "container_audits_passed": 6, - "container_audits_since": "1333145374.1373529"}) + self.assertEqual(self.fakecache.fakeout_calls, + [((['container_audits_passed', + 'container_auditor_pass_completed', + 'container_audits_since', + 'container_audits_failed'], + '/var/cache/swift/container.recon'), {})]) + self.assertEqual(rv, {"container_auditor_pass_completed": 0.24, + "container_audits_failed": 0, + "container_audits_passed": 6, + "container_audits_since": "1333145374.1373529"}) def test_get_auditor_info_object(self): from_cache_response = { @@ -832,11 +832,11 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_auditor_info('object') - self.assertEquals(self.fakecache.fakeout_calls, - [((['object_auditor_stats_ALL', - 'object_auditor_stats_ZBF'], - '/var/cache/swift/object.recon'), {})]) - self.assertEquals(rv, { + self.assertEqual(self.fakecache.fakeout_calls, + [((['object_auditor_stats_ALL', + 'object_auditor_stats_ZBF'], + '/var/cache/swift/object.recon'), {})]) + self.assertEqual(rv, { "object_auditor_stats_ALL": { "audit_time": 115.14418768882751, "bytes_processed": 234660, @@ -879,11 +879,11 @@ class TestReconSuccess(TestCase): self.fakecache.fakeout_calls = [] self.fakecache.fakeout = from_cache_response rv = self.app.get_auditor_info('object') - self.assertEquals(self.fakecache.fakeout_calls, - [((['object_auditor_stats_ALL', - 'object_auditor_stats_ZBF'], - '/var/cache/swift/object.recon'), {})]) - self.assertEquals(rv, { + self.assertEqual(self.fakecache.fakeout_calls, + [((['object_auditor_stats_ALL', + 'object_auditor_stats_ZBF'], + '/var/cache/swift/object.recon'), {})]) + self.assertEqual(rv, { "object_auditor_stats_ALL": { 'disk1': { "audit_time": 115.14418768882751, @@ -913,26 +913,26 @@ class TestReconSuccess(TestCase): self.mockos.ls_output = ['fakeone', 'faketwo'] self.mockos.ismount_output = False rv = self.app.get_unmounted() - self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})]) - self.assertEquals(rv, unmounted_resp) + self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})]) + self.assertEqual(rv, unmounted_resp) def test_get_unmounted_everything_normal(self): unmounted_resp = [] self.mockos.ls_output = ['fakeone', 'faketwo'] self.mockos.ismount_output = True rv = self.app.get_unmounted() - self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})]) - self.assertEquals(rv, unmounted_resp) + self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})]) + self.assertEqual(rv, unmounted_resp) def test_get_unmounted_checkmount_fail(self): unmounted_resp = [{'device': 'fakeone', 'mounted': 'brokendrive'}] self.mockos.ls_output = ['fakeone'] self.mockos.ismount_output = OSError('brokendrive') rv = self.app.get_unmounted() - self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})]) - self.assertEquals(self.mockos.ismount_calls, - [(('/srv/node/fakeone',), {})]) - self.assertEquals(rv, unmounted_resp) + self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})]) + self.assertEqual(self.mockos.ismount_calls, + [(('/srv/node/fakeone',), {})]) + self.assertEqual(rv, unmounted_resp) def test_no_get_unmounted(self): @@ -943,8 +943,8 @@ class TestReconSuccess(TestCase): self.mockos.ls_output = [] self.mockos.ismount_output = False rv = self.app.get_unmounted() - self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})]) - self.assertEquals(rv, unmounted_resp) + self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})]) + self.assertEqual(rv, unmounted_resp) def test_get_diskusage(self): # posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1963185, @@ -960,9 +960,9 @@ class TestReconSuccess(TestCase): self.mockos.statvfs_output = statvfs_content self.mockos.ismount_output = True rv = self.app.get_diskusage() - self.assertEquals(self.mockos.statvfs_calls, - [(('/srv/node/canhazdrive1',), {})]) - self.assertEquals(rv, du_resp) + self.assertEqual(self.mockos.statvfs_calls, + [(('/srv/node/canhazdrive1',), {})]) + self.assertEqual(rv, du_resp) def test_get_diskusage_checkmount_fail(self): du_resp = [{'device': 'canhazdrive1', 'avail': '', @@ -970,10 +970,10 @@ class TestReconSuccess(TestCase): self.mockos.ls_output = ['canhazdrive1'] self.mockos.ismount_output = OSError('brokendrive') rv = self.app.get_diskusage() - self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})]) - self.assertEquals(self.mockos.ismount_calls, - [(('/srv/node/canhazdrive1',), {})]) - self.assertEquals(rv, du_resp) + self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})]) + self.assertEqual(self.mockos.ismount_calls, + [(('/srv/node/canhazdrive1',), {})]) + self.assertEqual(rv, du_resp) @mock.patch("swift.common.middleware.recon.check_mount", fake_check_mount) def test_get_diskusage_oserror(self): @@ -981,7 +981,7 @@ class TestReconSuccess(TestCase): 'mounted': 'Input/Output Error', 'used': '', 'size': ''}] self.mockos.ls_output = ['canhazdrive1'] rv = self.app.get_diskusage() - self.assertEquals(rv, du_resp) + self.assertEqual(rv, du_resp) def test_get_quarantine_count(self): dirs = [['sda'], ['accounts', 'containers', 'objects', 'objects-1']] @@ -1003,9 +1003,9 @@ class TestReconSuccess(TestCase): with mock.patch("os.path.exists", fake_exists): with mock.patch("os.listdir", fake_listdir): rv = self.app.get_quarantine_count() - self.assertEquals(rv, {'objects': 4, 'accounts': 2, 'policies': - {'1': {'objects': 2}, '0': {'objects': 2}}, - 'containers': 2}) + self.assertEqual(rv, {'objects': 4, 'accounts': 2, 'policies': + {'1': {'objects': 2}, '0': {'objects': 2}}, + 'containers': 2}) def test_get_socket_info(self): sockstat_content = ['sockets: used 271', @@ -1015,7 +1015,7 @@ class TestReconSuccess(TestCase): ''] oart = OpenAndReadTester(sockstat_content) self.app.get_socket_info(openr=oart.open) - self.assertEquals(oart.open_calls, [ + self.assertEqual(oart.open_calls, [ (('/proc/net/sockstat', 'r'), {}), (('/proc/net/sockstat6', 'r'), {})]) @@ -1023,10 +1023,10 @@ class TestReconSuccess(TestCase): from_cache_response = {'drive_audit_errors': 7} self.fakecache.fakeout = from_cache_response rv = self.app.get_driveaudit_error() - self.assertEquals(self.fakecache.fakeout_calls, - [((['drive_audit_errors'], - '/var/cache/swift/drive.recon'), {})]) - self.assertEquals(rv, {'drive_audit_errors': 7}) + self.assertEqual(self.fakecache.fakeout_calls, + [((['drive_audit_errors'], + '/var/cache/swift/drive.recon'), {})]) + self.assertEqual(rv, {'drive_audit_errors': 7}) def test_get_time(self): def fake_time(): @@ -1035,7 +1035,7 @@ class TestReconSuccess(TestCase): with mock.patch("time.time", fake_time): now = fake_time() rv = self.app.get_time() - self.assertEquals(rv, now) + self.assertEqual(rv, now) class TestReconMiddleware(unittest.TestCase): @@ -1072,40 +1072,40 @@ class TestReconMiddleware(unittest.TestCase): get_mem_resp = ['{"memtest": "1"}'] req = Request.blank('/recon/mem', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_mem_resp) + self.assertEqual(resp, get_mem_resp) def test_recon_get_version(self): req = Request.blank('/recon/version', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, [utils.json.dumps({'version': swiftver})]) + self.assertEqual(resp, [utils.json.dumps({'version': swiftver})]) def test_recon_get_load(self): get_load_resp = ['{"loadtest": "1"}'] req = Request.blank('/recon/load', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_load_resp) + self.assertEqual(resp, get_load_resp) def test_recon_get_async(self): get_async_resp = ['{"asynctest": "1"}'] req = Request.blank('/recon/async', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_async_resp) + self.assertEqual(resp, get_async_resp) def test_get_device_info(self): get_device_resp = ['{"/srv/1/node": ["sdb1"]}'] req = Request.blank('/recon/devices', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_device_resp) + self.assertEqual(resp, get_device_resp) def test_recon_get_replication_notype(self): get_replication_resp = ['{"replicationtest": "1"}'] req = Request.blank('/recon/replication', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_replication_resp) - self.assertEquals(self.frecon.fake_replication_rtype, 'object') + self.assertEqual(resp, get_replication_resp) + self.assertEqual(self.frecon.fake_replication_rtype, 'object') self.frecon.fake_replication_rtype = None def test_recon_get_replication_all(self): @@ -1114,22 +1114,22 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/replication/account', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_replication_resp) - self.assertEquals(self.frecon.fake_replication_rtype, 'account') + self.assertEqual(resp, get_replication_resp) + self.assertEqual(self.frecon.fake_replication_rtype, 'account') self.frecon.fake_replication_rtype = None # test container req = Request.blank('/recon/replication/container', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_replication_resp) - self.assertEquals(self.frecon.fake_replication_rtype, 'container') + self.assertEqual(resp, get_replication_resp) + self.assertEqual(self.frecon.fake_replication_rtype, 'container') self.frecon.fake_replication_rtype = None # test object req = Request.blank('/recon/replication/object', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_replication_resp) - self.assertEquals(self.frecon.fake_replication_rtype, 'object') + self.assertEqual(resp, get_replication_resp) + self.assertEqual(self.frecon.fake_replication_rtype, 'object') self.frecon.fake_replication_rtype = None def test_recon_get_auditor_invalid(self): @@ -1137,34 +1137,34 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/auditor/invalid', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_auditor_resp) + self.assertEqual(resp, get_auditor_resp) def test_recon_get_auditor_notype(self): get_auditor_resp = ['Invalid path: /recon/auditor'] req = Request.blank('/recon/auditor', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_auditor_resp) + self.assertEqual(resp, get_auditor_resp) def test_recon_get_auditor_all(self): get_auditor_resp = ['{"auditortest": "1"}'] req = Request.blank('/recon/auditor/account', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_auditor_resp) - self.assertEquals(self.frecon.fake_auditor_rtype, 'account') + self.assertEqual(resp, get_auditor_resp) + self.assertEqual(self.frecon.fake_auditor_rtype, 'account') self.frecon.fake_auditor_rtype = None req = Request.blank('/recon/auditor/container', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_auditor_resp) - self.assertEquals(self.frecon.fake_auditor_rtype, 'container') + self.assertEqual(resp, get_auditor_resp) + self.assertEqual(self.frecon.fake_auditor_rtype, 'container') self.frecon.fake_auditor_rtype = None req = Request.blank('/recon/auditor/object', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_auditor_resp) - self.assertEquals(self.frecon.fake_auditor_rtype, 'object') + self.assertEqual(resp, get_auditor_resp) + self.assertEqual(self.frecon.fake_auditor_rtype, 'object') self.frecon.fake_auditor_rtype = None def test_recon_get_updater_invalid(self): @@ -1172,28 +1172,28 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/updater/invalid', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_updater_resp) + self.assertEqual(resp, get_updater_resp) def test_recon_get_updater_notype(self): get_updater_resp = ['Invalid path: /recon/updater'] req = Request.blank('/recon/updater', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_updater_resp) + self.assertEqual(resp, get_updater_resp) def test_recon_get_updater(self): get_updater_resp = ['{"updatertest": "1"}'] req = Request.blank('/recon/updater/container', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(self.frecon.fake_updater_rtype, 'container') + self.assertEqual(self.frecon.fake_updater_rtype, 'container') self.frecon.fake_updater_rtype = None - self.assertEquals(resp, get_updater_resp) + self.assertEqual(resp, get_updater_resp) req = Request.blank('/recon/updater/object', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_updater_resp) - self.assertEquals(self.frecon.fake_updater_rtype, 'object') + self.assertEqual(resp, get_updater_resp) + self.assertEqual(self.frecon.fake_updater_rtype, 'object') self.frecon.fake_updater_rtype = None def test_recon_get_expirer_invalid(self): @@ -1201,22 +1201,22 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/expirer/invalid', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_updater_resp) + self.assertEqual(resp, get_updater_resp) def test_recon_get_expirer_notype(self): get_updater_resp = ['Invalid path: /recon/expirer'] req = Request.blank('/recon/expirer', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_updater_resp) + self.assertEqual(resp, get_updater_resp) def test_recon_get_expirer_object(self): get_expirer_resp = ['{"expirertest": "1"}'] req = Request.blank('/recon/expirer/object', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_expirer_resp) - self.assertEquals(self.frecon.fake_expirer_rtype, 'object') + self.assertEqual(resp, get_expirer_resp) + self.assertEqual(self.frecon.fake_expirer_rtype, 'object') self.frecon.fake_updater_rtype = None def test_recon_get_mounted(self): @@ -1224,7 +1224,7 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/mounted', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_mounted_resp) + self.assertEqual(resp, get_mounted_resp) def test_recon_get_unmounted(self): get_unmounted_resp = ['{"unmountedtest": "1"}'] @@ -1232,7 +1232,7 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/unmounted', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_unmounted_resp) + self.assertEqual(resp, get_unmounted_resp) def test_recon_no_get_unmounted(self): get_unmounted_resp = '[]' @@ -1240,73 +1240,73 @@ class TestReconMiddleware(unittest.TestCase): req = Request.blank('/recon/unmounted', environ={'REQUEST_METHOD': 'GET'}) resp = ''.join(self.app(req.environ, start_response)) - self.assertEquals(resp, get_unmounted_resp) + self.assertEqual(resp, get_unmounted_resp) def test_recon_get_diskusage(self): get_diskusage_resp = ['{"diskusagetest": "1"}'] req = Request.blank('/recon/diskusage', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_diskusage_resp) + self.assertEqual(resp, get_diskusage_resp) def test_recon_get_ringmd5(self): get_ringmd5_resp = ['{"ringmd5test": "1"}'] req = Request.blank('/recon/ringmd5', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_ringmd5_resp) + self.assertEqual(resp, get_ringmd5_resp) def test_recon_get_swiftconfmd5(self): get_swiftconfmd5_resp = ['{"/etc/swift/swift.conf": "abcdef"}'] req = Request.blank('/recon/swiftconfmd5', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_swiftconfmd5_resp) + self.assertEqual(resp, get_swiftconfmd5_resp) def test_recon_get_quarantined(self): get_quarantined_resp = ['{"quarantinedtest": "1"}'] req = Request.blank('/recon/quarantined', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_quarantined_resp) + self.assertEqual(resp, get_quarantined_resp) def test_recon_get_sockstat(self): get_sockstat_resp = ['{"sockstattest": "1"}'] req = Request.blank('/recon/sockstat', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_sockstat_resp) + self.assertEqual(resp, get_sockstat_resp) def test_recon_invalid_path(self): req = Request.blank('/recon/invalid', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, ['Invalid path: /recon/invalid']) + self.assertEqual(resp, ['Invalid path: /recon/invalid']) def test_no_content(self): self.app.get_load = self.frecon.nocontent req = Request.blank('/recon/load', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, ['Internal server error.']) + self.assertEqual(resp, ['Internal server error.']) def test_recon_pass(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, 'FAKE APP') + self.assertEqual(resp, 'FAKE APP') def test_recon_get_driveaudit(self): get_driveaudit_resp = ['{"driveaudittest": "1"}'] req = Request.blank('/recon/driveaudit', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_driveaudit_resp) + self.assertEqual(resp, get_driveaudit_resp) def test_recon_get_time(self): get_time_resp = ['{"timetest": "1"}'] req = Request.blank('/recon/time', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEquals(resp, get_time_resp) + self.assertEqual(resp, get_time_resp) if __name__ == '__main__': unittest.main() diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index f8455a96e6..59fb16b7f6 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -108,8 +108,8 @@ class TestSloMiddleware(SloTestCase): def test_handle_multipart_no_obj(self): req = Request.blank('/') resp_iter = self.slo(req.environ, fake_start_response) - self.assertEquals(self.app.calls, [('GET', '/')]) - self.assertEquals(''.join(resp_iter), 'passed') + self.assertEqual(self.app.calls, [('GET', '/')]) + self.assertEqual(''.join(resp_iter), 'passed') def test_slo_header_assigned(self): req = Request.blank( @@ -132,15 +132,15 @@ class TestSloMiddleware(SloTestCase): data = json.dumps( [{'path': '/cont/object', 'etag': 'etagoftheobjecitsegment', 'size_bytes': 100}]) - self.assertEquals('/cont/object', - slo.parse_input(data)[0]['path']) + self.assertEqual('/cont/object', + slo.parse_input(data)[0]['path']) data = json.dumps( [{'path': '/cont/object', 'etag': 'etagoftheobjecitsegment', 'size_bytes': 100, 'range': '0-40,30-90'}]) parsed = slo.parse_input(data) - self.assertEquals('/cont/object', parsed[0]['path']) - self.assertEquals([(0, 40), (30, 90)], parsed[0]['range'].ranges) + self.assertEqual('/cont/object', parsed[0]['path']) + self.assertEqual([(0, 40), (30, 90)], parsed[0]['range'].ranges) class TestSloPutManifest(SloTestCase): @@ -213,7 +213,7 @@ class TestSloPutManifest(SloTestCase): self.slo.handle_multipart_put(req, fake_start_response) except HTTPException as e: pass - self.assertEquals(e.status_int, 413) + self.assertEqual(e.status_int, 413) with patch.object(self.slo, 'max_manifest_segments', 0): req = Request.blank('/v1/a/c/o', body=test_json_data) @@ -222,7 +222,7 @@ class TestSloPutManifest(SloTestCase): self.slo.handle_multipart_put(req, fake_start_response) except HTTPException as e: pass - self.assertEquals(e.status_int, 413) + self.assertEqual(e.status_int, 413) with patch.object(self.slo, 'min_segment_size', 1000): test_json_data_2obj = json.dumps( @@ -237,20 +237,20 @@ class TestSloPutManifest(SloTestCase): self.slo.handle_multipart_put(req, fake_start_response) except HTTPException as e: pass - self.assertEquals(e.status_int, 400) + self.assertEqual(e.status_int, 400) req = Request.blank('/v1/a/c/o', headers={'X-Copy-From': 'lala'}) try: self.slo.handle_multipart_put(req, fake_start_response) except HTTPException as e: pass - self.assertEquals(e.status_int, 405) + self.assertEqual(e.status_int, 405) # ignores requests to / req = Request.blank( '/?multipart-manifest=put', environ={'REQUEST_METHOD': 'PUT'}, body=test_json_data) - self.assertEquals( + self.assertEqual( list(self.slo.handle_multipart_put(req, fake_start_response)), ['passed']) @@ -310,7 +310,7 @@ class TestSloPutManifest(SloTestCase): self.slo.handle_multipart_put(req, fake_start_response) except HTTPException as e: pass - self.assertEquals(e.status_int, 400) + self.assertEqual(e.status_int, 400) def test_handle_multipart_put_success_unicode(self): test_json_data = json.dumps([{'path': u'/cont/object\u2661', @@ -331,7 +331,7 @@ class TestSloPutManifest(SloTestCase): environ={'REQUEST_METHOD': 'PUT'}, headers={'Accept': 'test'}, body=test_xml_data) no_xml = self.slo(req.environ, fake_start_response) - self.assertEquals(no_xml, ['Manifest must be valid json.']) + self.assertEqual(no_xml, ['Manifest must be valid json.']) def test_handle_multipart_put_bad_data(self): bad_data = json.dumps([{'path': '/cont/object', @@ -374,7 +374,7 @@ class TestSloPutManifest(SloTestCase): '/v1/AUTH_test/checktest/man_3?multipart-manifest=put', environ={'REQUEST_METHOD': 'PUT'}, body=good_data) status, headers, body = self.call_slo(req) - self.assertEquals(self.app.call_count, 3) + self.assertEqual(self.app.call_count, 3) # go behind SLO's back and see what actually got stored req = Request.blank( @@ -386,9 +386,9 @@ class TestSloPutManifest(SloTestCase): headers = dict(headers) manifest_data = json.loads(body) self.assertTrue(headers['Content-Type'].endswith(';swift_bytes=3')) - self.assertEquals(len(manifest_data), 2) - self.assertEquals(manifest_data[0]['hash'], 'a') - self.assertEquals(manifest_data[0]['bytes'], 1) + self.assertEqual(len(manifest_data), 2) + self.assertEqual(manifest_data[0]['hash'], 'a') + self.assertEqual(manifest_data[0]['bytes'], 1) self.assertTrue( not manifest_data[0]['last_modified'].startswith('2012')) self.assertTrue(manifest_data[1]['last_modified'].startswith('2012')) @@ -407,19 +407,19 @@ class TestSloPutManifest(SloTestCase): body=bad_data) status, headers, body = self.call_slo(req) - self.assertEquals(self.app.call_count, 5) + self.assertEqual(self.app.call_count, 5) errors = json.loads(body)['Errors'] - self.assertEquals(len(errors), 5) - self.assertEquals(errors[0][0], '/checktest/a_1') - self.assertEquals(errors[0][1], 'Size Mismatch') - self.assertEquals(errors[1][0], '/checktest/badreq') - self.assertEquals(errors[1][1], '400 Bad Request') - self.assertEquals(errors[2][0], '/checktest/b_2') - self.assertEquals(errors[2][1], 'Etag Mismatch') - self.assertEquals(errors[3][0], '/checktest/slob') - self.assertEquals(errors[3][1], 'Size Mismatch') - self.assertEquals(errors[4][0], '/checktest/slob') - self.assertEquals(errors[4][1], 'Etag Mismatch') + self.assertEqual(len(errors), 5) + self.assertEqual(errors[0][0], '/checktest/a_1') + self.assertEqual(errors[0][1], 'Size Mismatch') + self.assertEqual(errors[1][0], '/checktest/badreq') + self.assertEqual(errors[1][1], '400 Bad Request') + self.assertEqual(errors[2][0], '/checktest/b_2') + self.assertEqual(errors[2][1], 'Etag Mismatch') + self.assertEqual(errors[3][0], '/checktest/slob') + self.assertEqual(errors[3][1], 'Size Mismatch') + self.assertEqual(errors[4][0], '/checktest/slob') + self.assertEqual(errors[4][1], 'Etag Mismatch') def test_handle_multipart_put_manifest_equal_slo(self): test_json_data = json.dumps([{'path': '/cont/object', @@ -469,7 +469,7 @@ class TestSloPutManifest(SloTestCase): '/v1/AUTH_test/checktest/man_3?multipart-manifest=put', environ={'REQUEST_METHOD': 'PUT'}, body=good_data) status, headers, body = self.call_slo(req) - self.assertEquals(self.app.call_count, 3) + self.assertEqual(self.app.call_count, 3) # Check that we still populated the manifest properly from our HEADs req = Request.blank( @@ -479,8 +479,8 @@ class TestSloPutManifest(SloTestCase): environ={'REQUEST_METHOD': 'GET'}) status, headers, body = self.call_app(req) manifest_data = json.loads(body) - self.assertEquals(1, manifest_data[0]['bytes']) - self.assertEquals(2, manifest_data[1]['bytes']) + self.assertEqual(1, manifest_data[0]['bytes']) + self.assertEqual(2, manifest_data[1]['bytes']) def test_handle_multipart_put_skip_size_check_still_uses_min_size(self): with patch.object(self.slo, 'min_segment_size', 50): @@ -493,7 +493,7 @@ class TestSloPutManifest(SloTestCase): req = Request.blank('/v1/AUTH_test/c/o', body=test_json_data) with self.assertRaises(HTTPException) as cm: self.slo.handle_multipart_put(req, fake_start_response) - self.assertEquals(cm.exception.status_int, 400) + self.assertEqual(cm.exception.status_int, 400) def test_handle_multipart_put_skip_etag_check(self): good_data = json.dumps( @@ -503,7 +503,7 @@ class TestSloPutManifest(SloTestCase): '/v1/AUTH_test/checktest/man_3?multipart-manifest=put', environ={'REQUEST_METHOD': 'PUT'}, body=good_data) status, headers, body = self.call_slo(req) - self.assertEquals(self.app.call_count, 3) + self.assertEqual(self.app.call_count, 3) # Check that we still populated the manifest properly from our HEADs req = Request.blank( @@ -513,8 +513,8 @@ class TestSloPutManifest(SloTestCase): environ={'REQUEST_METHOD': 'GET'}) status, headers, body = self.call_app(req) manifest_data = json.loads(body) - self.assertEquals('a', manifest_data[0]['hash']) - self.assertEquals('b', manifest_data[1]['hash']) + self.assertEqual('a', manifest_data[0]['hash']) + self.assertEqual('b', manifest_data[1]['hash']) def test_handle_unsatisfiable_ranges(self): bad_data = json.dumps( @@ -559,18 +559,18 @@ class TestSloPutManifest(SloTestCase): environ={'REQUEST_METHOD': 'GET'}) status, headers, body = self.call_app(req) manifest_data = json.loads(body) - self.assertEquals('a', manifest_data[0]['hash']) + self.assertEqual('a', manifest_data[0]['hash']) self.assertNotIn('range', manifest_data[0]) self.assertNotIn('segment_bytes', manifest_data[0]) - self.assertEquals('b', manifest_data[1]['hash']) - self.assertEquals('1-1', manifest_data[1]['range']) + self.assertEqual('b', manifest_data[1]['hash']) + self.assertEqual('1-1', manifest_data[1]['range']) - self.assertEquals('b', manifest_data[2]['hash']) - self.assertEquals('0-0', manifest_data[2]['range']) + self.assertEqual('b', manifest_data[2]['hash']) + self.assertEqual('0-0', manifest_data[2]['range']) - self.assertEquals('etagoftheobjectsegment', manifest_data[3]['hash']) - self.assertEquals('10-40', manifest_data[3]['range']) + self.assertEqual('etagoftheobjectsegment', manifest_data[3]['hash']) + self.assertEqual('10-40', manifest_data[3]['range']) def test_handle_multiple_ranges_error(self): good_data = json.dumps( @@ -585,7 +585,7 @@ class TestSloPutManifest(SloTestCase): environ={'REQUEST_METHOD': 'PUT'}, body=good_data) status, headers, body = self.call_slo(req) self.assertEqual(status, '400 Bad Request') - self.assertEquals(self.app.call_count, 3) + self.assertEqual(self.app.call_count, 3) self.assertEqual(body, '\n'.join([ 'Errors:', '/checktest/b_2, Multiple Ranges', @@ -707,7 +707,7 @@ class TestSloDeleteManifest(SloTestCase): '/v1/AUTH_test/deltest/man', environ={'REQUEST_METHOD': 'DELETE'}) self.slo(req.environ, fake_start_response) - self.assertEquals(self.app.call_count, 1) + self.assertEqual(self.app.call_count, 1) def test_handle_multipart_delete_bad_utf8(self): req = Request.blank( @@ -715,10 +715,10 @@ class TestSloDeleteManifest(SloTestCase): environ={'REQUEST_METHOD': 'DELETE', 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') resp_data = json.loads(body) - self.assertEquals(resp_data['Response Status'], - '412 Precondition Failed') + self.assertEqual(resp_data['Response Status'], + '412 Precondition Failed') def test_handle_multipart_delete_whole_404(self): req = Request.blank( @@ -727,15 +727,15 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) resp_data = json.loads(body) - self.assertEquals( + self.assertEqual( self.app.calls, [('GET', '/v1/AUTH_test/deltest/man_404?multipart-manifest=get')]) - self.assertEquals(resp_data['Response Status'], '200 OK') - self.assertEquals(resp_data['Response Body'], '') - self.assertEquals(resp_data['Number Deleted'], 0) - self.assertEquals(resp_data['Number Not Found'], 1) - self.assertEquals(resp_data['Errors'], []) + self.assertEqual(resp_data['Response Status'], '200 OK') + self.assertEqual(resp_data['Response Body'], '') + self.assertEqual(resp_data['Number Deleted'], 0) + self.assertEqual(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Errors'], []) def test_handle_multipart_delete_segment_404(self): req = Request.blank( @@ -744,7 +744,7 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) resp_data = json.loads(body) - self.assertEquals( + self.assertEqual( self.app.calls, [('GET', '/v1/AUTH_test/deltest/man?multipart-manifest=get'), @@ -754,16 +754,16 @@ class TestSloDeleteManifest(SloTestCase): '/v1/AUTH_test/deltest/b_2?multipart-manifest=delete'), ('DELETE', '/v1/AUTH_test/deltest/man?multipart-manifest=delete')]) - self.assertEquals(resp_data['Response Status'], '200 OK') - self.assertEquals(resp_data['Number Deleted'], 2) - self.assertEquals(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Response Status'], '200 OK') + self.assertEqual(resp_data['Number Deleted'], 2) + self.assertEqual(resp_data['Number Not Found'], 1) def test_handle_multipart_delete_whole(self): req = Request.blank( '/v1/AUTH_test/deltest/man-all-there?multipart-manifest=delete', environ={'REQUEST_METHOD': 'DELETE'}) self.call_slo(req) - self.assertEquals( + self.assertEqual( self.app.calls, [('GET', '/v1/AUTH_test/deltest/man-all-there?multipart-manifest=get'), @@ -778,7 +778,7 @@ class TestSloDeleteManifest(SloTestCase): 'multipart-manifest=delete', environ={'REQUEST_METHOD': 'DELETE'}) self.call_slo(req) - self.assertEquals( + self.assertEqual( set(self.app.calls), set([('GET', '/v1/AUTH_test/deltest/' + 'manifest-with-submanifest?multipart-manifest=get'), @@ -807,11 +807,11 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) with patch.object(slo, 'MAX_BUFFERED_SLO_SEGMENTS', 1): status, headers, body = self.call_slo(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') resp_data = json.loads(body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Response Body'], - 'Too many buffered slo segments to delete.') + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Response Body'], + 'Too many buffered slo segments to delete.') def test_handle_multipart_delete_nested_404(self): req = Request.blank( @@ -821,7 +821,7 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) resp_data = json.loads(body) - self.assertEquals( + self.assertEqual( self.app.calls, [('GET', '/v1/AUTH_test/deltest/' + 'manifest-missing-submanifest?multipart-manifest=get'), @@ -831,11 +831,11 @@ class TestSloDeleteManifest(SloTestCase): ('DELETE', '/v1/AUTH_test/deltest/d_3?multipart-manifest=delete'), ('DELETE', '/v1/AUTH_test/deltest/' + 'manifest-missing-submanifest?multipart-manifest=delete')]) - self.assertEquals(resp_data['Response Status'], '200 OK') - self.assertEquals(resp_data['Response Body'], '') - self.assertEquals(resp_data['Number Deleted'], 3) - self.assertEquals(resp_data['Number Not Found'], 1) - self.assertEquals(resp_data['Errors'], []) + self.assertEqual(resp_data['Response Status'], '200 OK') + self.assertEqual(resp_data['Response Body'], '') + self.assertEqual(resp_data['Number Deleted'], 3) + self.assertEqual(resp_data['Number Not Found'], 1) + self.assertEqual(resp_data['Errors'], []) def test_handle_multipart_delete_nested_401(self): self.app.register( @@ -848,11 +848,11 @@ class TestSloDeleteManifest(SloTestCase): environ={'REQUEST_METHOD': 'DELETE', 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') resp_data = json.loads(body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Errors'], - [['/deltest/submanifest', '401 Unauthorized']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Errors'], + [['/deltest/submanifest', '401 Unauthorized']]) def test_handle_multipart_delete_nested_500(self): self.app.register( @@ -865,12 +865,12 @@ class TestSloDeleteManifest(SloTestCase): environ={'REQUEST_METHOD': 'DELETE', 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') resp_data = json.loads(body) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Errors'], - [['/deltest/submanifest', - 'Unable to load SLO manifest or segment.']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Errors'], + [['/deltest/submanifest', + 'Unable to load SLO manifest or segment.']]) def test_handle_multipart_delete_not_a_manifest(self): req = Request.blank( @@ -879,15 +879,15 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) resp_data = json.loads(body) - self.assertEquals( + self.assertEqual( self.app.calls, [('GET', '/v1/AUTH_test/deltest/a_1?multipart-manifest=get')]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Response Body'], '') - self.assertEquals(resp_data['Number Deleted'], 0) - self.assertEquals(resp_data['Number Not Found'], 0) - self.assertEquals(resp_data['Errors'], - [['/deltest/a_1', 'Not an SLO manifest']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Response Body'], '') + self.assertEqual(resp_data['Number Deleted'], 0) + self.assertEqual(resp_data['Number Not Found'], 0) + self.assertEqual(resp_data['Errors'], + [['/deltest/a_1', 'Not an SLO manifest']]) def test_handle_multipart_delete_bad_json(self): req = Request.blank( @@ -896,16 +896,16 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) resp_data = json.loads(body) - self.assertEquals(self.app.calls, - [('GET', '/v1/AUTH_test/deltest/' + - 'manifest-badjson?multipart-manifest=get')]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Response Body'], '') - self.assertEquals(resp_data['Number Deleted'], 0) - self.assertEquals(resp_data['Number Not Found'], 0) - self.assertEquals(resp_data['Errors'], - [['/deltest/manifest-badjson', - 'Unable to load SLO manifest']]) + self.assertEqual(self.app.calls, + [('GET', '/v1/AUTH_test/deltest/' + + 'manifest-badjson?multipart-manifest=get')]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Response Body'], '') + self.assertEqual(resp_data['Number Deleted'], 0) + self.assertEqual(resp_data['Number Not Found'], 0) + self.assertEqual(resp_data['Errors'], + [['/deltest/manifest-badjson', + 'Unable to load SLO manifest']]) def test_handle_multipart_delete_401(self): req = Request.blank( @@ -915,7 +915,7 @@ class TestSloDeleteManifest(SloTestCase): 'HTTP_ACCEPT': 'application/json'}) status, headers, body = self.call_slo(req) resp_data = json.loads(body) - self.assertEquals( + self.assertEqual( self.app.calls, [('GET', '/v1/AUTH_test/deltest/' + 'manifest-with-unauth-segment?multipart-manifest=get'), @@ -924,12 +924,12 @@ class TestSloDeleteManifest(SloTestCase): 'q_17?multipart-manifest=delete'), ('DELETE', '/v1/AUTH_test/deltest/' + 'manifest-with-unauth-segment?multipart-manifest=delete')]) - self.assertEquals(resp_data['Response Status'], '400 Bad Request') - self.assertEquals(resp_data['Response Body'], '') - self.assertEquals(resp_data['Number Deleted'], 2) - self.assertEquals(resp_data['Number Not Found'], 0) - self.assertEquals(resp_data['Errors'], - [['/deltest-unauth/q_17', '401 Unauthorized']]) + self.assertEqual(resp_data['Response Status'], '400 Bad Request') + self.assertEqual(resp_data['Response Body'], '') + self.assertEqual(resp_data['Number Deleted'], 2) + self.assertEqual(resp_data['Number Not Found'], 0) + self.assertEqual(resp_data['Errors'], + [['/deltest-unauth/q_17', '401 Unauthorized']]) class TestSloHeadManifest(SloTestCase): diff --git a/test/unit/common/middleware/test_staticweb.py b/test/unit/common/middleware/test_staticweb.py index c0836a341b..c9ce97cf5e 100644 --- a/test/unit/common/middleware/test_staticweb.py +++ b/test/unit/common/middleware/test_staticweb.py @@ -393,117 +393,117 @@ class TestStaticWeb(unittest.TestCase): def test_app_set(self): app = FakeApp() sw = staticweb.filter_factory({})(app) - self.assertEquals(sw.app, app) + self.assertEqual(sw.app, app) def test_conf_set(self): conf = {'blah': 1} sw = staticweb.filter_factory(conf)(FakeApp()) - self.assertEquals(sw.conf, conf) + self.assertEqual(sw.conf, conf) def test_root(self): resp = Request.blank('/').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_version(self): resp = Request.blank('/v1').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 412) + self.assertEqual(resp.status_int, 412) def test_account(self): resp = Request.blank('/v1/a').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) def test_container1(self): resp = Request.blank('/v1/a/c1').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) def test_container1_web_mode_explicitly_off(self): resp = Request.blank('/v1/a/c1', headers={'x-web-mode': 'false'}).get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) def test_container1_web_mode_explicitly_on(self): resp = Request.blank('/v1/a/c1', headers={'x-web-mode': 'true'}).get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_container2(self): resp = Request.blank('/v1/a/c2').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'text/plain') - self.assertEquals(len(resp.body.split('\n')), - int(resp.headers['x-container-object-count'])) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'text/plain') + self.assertEqual(len(resp.body.split('\n')), + int(resp.headers['x-container-object-count'])) def test_container2_web_mode_explicitly_off(self): resp = Request.blank( '/v1/a/c2', headers={'x-web-mode': 'false'}).get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'text/plain') - self.assertEquals(len(resp.body.split('\n')), - int(resp.headers['x-container-object-count'])) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'text/plain') + self.assertEqual(len(resp.body.split('\n')), + int(resp.headers['x-container-object-count'])) def test_container2_web_mode_explicitly_on(self): resp = Request.blank( '/v1/a/c2', headers={'x-web-mode': 'true'}).get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_container2onetxt(self): resp = Request.blank( '/v1/a/c2/one.txt').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_container2json(self): resp = Request.blank( '/v1/a/c2?format=json').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(len(json.loads(resp.body)), - int(resp.headers['x-container-object-count'])) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'application/json') + self.assertEqual(len(json.loads(resp.body)), + int(resp.headers['x-container-object-count'])) def test_container2json_web_mode_explicitly_off(self): resp = Request.blank( '/v1/a/c2?format=json', headers={'x-web-mode': 'false'}).get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(len(json.loads(resp.body)), - int(resp.headers['x-container-object-count'])) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.content_type, 'application/json') + self.assertEqual(len(json.loads(resp.body)), + int(resp.headers['x-container-object-count'])) def test_container2json_web_mode_explicitly_on(self): resp = Request.blank( '/v1/a/c2?format=json', headers={'x-web-mode': 'true'}).get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_container3(self): resp = Request.blank('/v1/a/c3').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 301) - self.assertEquals(resp.headers['location'], - 'http://localhost/v1/a/c3/') + self.assertEqual(resp.status_int, 301) + self.assertEqual(resp.headers['location'], + 'http://localhost/v1/a/c3/') def test_container3indexhtml(self): resp = Request.blank('/v1/a/c3/').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertTrue('Test main index.html file.' in resp.body) def test_container3subsubdir(self): resp = Request.blank( '/v1/a/c3/subdir3/subsubdir').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 301) + self.assertEqual(resp.status_int, 301) def test_container3subsubdircontents(self): resp = Request.blank( '/v1/a/c3/subdir3/subsubdir/').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.body, 'index file') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.body, 'index file') def test_container3subdir(self): resp = Request.blank( '/v1/a/c3/subdir/').get_response(self.test_staticweb) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body) self.assertTrue('' in resp.body) self.assertTrue('' not in resp.body) self.assertTrue('c11 subdir index' in resp.body) def test_container11subdirmarkermatchdirtype(self): resp = Request.blank('/v1/a/c11a/subdir/').get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('Index File Not Found' in resp.body) def test_container11subdirmarkeraltdirtype(self): resp = Request.blank('/v1/a/c11a/subdir2/').get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) def test_container11subdirmarkerinvaliddirtype(self): resp = Request.blank('/v1/a/c11a/subdir3/').get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) def test_container12unredirectedrequest(self): resp = Request.blank('/v1/a/c12/').get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertTrue('index file' in resp.body) def test_container_404_has_css(self): resp = Request.blank('/v1/a/c13/').get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('listing.css' in resp.body) def test_container_404_has_no_css(self): resp = Request.blank('/v1/a/c7/').get_response( self.test_staticweb) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('listing.css' not in resp.body) self.assertTrue(' 10) @@ -527,54 +527,54 @@ class TestAuth(unittest.TestCase): cache_entry = (time() + 3600, 'AUTH_acct') req.environ['swift.cache'].set(cache_key, cache_entry) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) def test_get_token_fail(self): resp = self._make_request('/auth/v1.0').get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="unknown"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="unknown"') resp = self._make_request( '/auth/v1.0', headers={'X-Auth-User': 'act:usr', 'X-Auth-Key': 'key'}).get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="act"') + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="act"') def test_get_token_fail_invalid_x_auth_user_format(self): resp = self._make_request( '/auth/v1/act/auth', headers={'X-Auth-User': 'usr', 'X-Auth-Key': 'key'}).get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="act"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="act"') def test_get_token_fail_non_matching_account_in_request(self): resp = self._make_request( '/auth/v1/act/auth', headers={'X-Auth-User': 'act2:usr', 'X-Auth-Key': 'key'}).get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="act"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="act"') def test_get_token_fail_bad_path(self): resp = self._make_request( '/auth/v1/act/auth/invalid', headers={'X-Auth-User': 'act:usr', 'X-Auth-Key': 'key'}).get_response(self.test_auth) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) def test_get_token_fail_missing_key(self): resp = self._make_request( '/auth/v1/act/auth', headers={'X-Auth-User': 'act:usr'}).get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="act"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="act"') def test_object_name_containing_slash(self): test_auth = auth.filter_factory({'user_acct_user': 'testing'})( @@ -585,7 +585,7 @@ class TestAuth(unittest.TestCase): cache_entry = (time() + 3600, 'AUTH_acct') req.environ['swift.cache'].set(cache_key, cache_entry) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) def test_storage_url_default(self): self.test_auth = \ @@ -597,9 +597,9 @@ class TestAuth(unittest.TestCase): req.environ['SERVER_NAME'] = 'bob' req.environ['SERVER_PORT'] = '1234' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['x-storage-url'], - 'http://bob:1234/v1/AUTH_test') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['x-storage-url'], + 'http://bob:1234/v1/AUTH_test') def test_storage_url_based_on_host(self): self.test_auth = \ @@ -611,9 +611,9 @@ class TestAuth(unittest.TestCase): req.environ['SERVER_NAME'] = 'bob' req.environ['SERVER_PORT'] = '1234' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['x-storage-url'], - 'http://somehost:5678/v1/AUTH_test') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['x-storage-url'], + 'http://somehost:5678/v1/AUTH_test') def test_storage_url_overridden_scheme(self): self.test_auth = \ @@ -626,9 +626,9 @@ class TestAuth(unittest.TestCase): req.environ['SERVER_NAME'] = 'bob' req.environ['SERVER_PORT'] = '1234' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['x-storage-url'], - 'fake://somehost:5678/v1/AUTH_test') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['x-storage-url'], + 'fake://somehost:5678/v1/AUTH_test') def test_use_old_token_from_memcached(self): self.test_auth = \ @@ -644,8 +644,8 @@ class TestAuth(unittest.TestCase): req.environ['swift.cache'].set('AUTH_/token/uuid_token', (time() + 180, 'test,test:tester')) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['x-auth-token'], 'uuid_token') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['x-auth-token'], 'uuid_token') def test_old_token_overdate(self): self.test_auth = \ @@ -661,9 +661,9 @@ class TestAuth(unittest.TestCase): req.environ['swift.cache'].set('AUTH_/token/uuid_token', (0, 'test,test:tester')) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertNotEquals(resp.headers['x-auth-token'], 'uuid_token') - self.assertEquals(resp.headers['x-auth-token'][:7], 'AUTH_tk') + self.assertEqual(resp.headers['x-auth-token'][:7], 'AUTH_tk') def test_old_token_with_old_data(self): self.test_auth = \ @@ -679,9 +679,9 @@ class TestAuth(unittest.TestCase): req.environ['swift.cache'].set('AUTH_/token/uuid_token', (time() + 99, 'test,test:tester,.role')) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertNotEquals(resp.headers['x-auth-token'], 'uuid_token') - self.assertEquals(resp.headers['x-auth-token'][:7], 'AUTH_tk') + self.assertEqual(resp.headers['x-auth-token'][:7], 'AUTH_tk') def test_reseller_admin_is_owner(self): orig_authorize = self.test_auth.authorize @@ -698,7 +698,7 @@ class TestAuth(unittest.TestCase): headers={'X-Auth-Token': 'AUTH_t'}) req.remote_user = '.reseller_admin' self.test_auth.authorize(req) - self.assertEquals(owner_values, [True]) + self.assertEqual(owner_values, [True]) def test_admin_is_owner(self): orig_authorize = self.test_auth.authorize @@ -716,7 +716,7 @@ class TestAuth(unittest.TestCase): headers={'X-Auth-Token': 'AUTH_t'}) req.remote_user = 'AUTH_cfa' self.test_auth.authorize(req) - self.assertEquals(owner_values, [True]) + self.assertEqual(owner_values, [True]) def test_regular_is_not_owner(self): orig_authorize = self.test_auth.authorize @@ -734,7 +734,7 @@ class TestAuth(unittest.TestCase): headers={'X-Auth-Token': 'AUTH_t'}) req.remote_user = 'act:usr' self.test_auth.authorize(req) - self.assertEquals(owner_values, [False]) + self.assertEqual(owner_values, [False]) def test_sync_request_success(self): self.test_auth.app = FakeApp(iter(NO_CONTENT_RESP * 1), @@ -746,7 +746,7 @@ class TestAuth(unittest.TestCase): 'x-timestamp': '123.456'}) req.remote_addr = '127.0.0.1' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) def test_sync_request_fail_key(self): self.test_auth.app = FakeApp(sync_key='secret') @@ -757,9 +757,9 @@ class TestAuth(unittest.TestCase): 'x-timestamp': '123.456'}) req.remote_addr = '127.0.0.1' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="AUTH_cfa"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="AUTH_cfa"') self.test_auth.app = FakeApp(sync_key='othersecret') req = self._make_request( @@ -769,9 +769,9 @@ class TestAuth(unittest.TestCase): 'x-timestamp': '123.456'}) req.remote_addr = '127.0.0.1' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="AUTH_cfa"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="AUTH_cfa"') self.test_auth.app = FakeApp(sync_key=None) req = self._make_request( @@ -781,9 +781,9 @@ class TestAuth(unittest.TestCase): 'x-timestamp': '123.456'}) req.remote_addr = '127.0.0.1' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="AUTH_cfa"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="AUTH_cfa"') def test_sync_request_fail_no_timestamp(self): self.test_auth.app = FakeApp(sync_key='secret') @@ -793,9 +793,9 @@ class TestAuth(unittest.TestCase): headers={'x-container-sync-key': 'secret'}) req.remote_addr = '127.0.0.1' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="AUTH_cfa"') + self.assertEqual(resp.status_int, 401) + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="AUTH_cfa"') def test_sync_request_success_lb_sync_host(self): self.test_auth.app = FakeApp(iter(NO_CONTENT_RESP * 1), @@ -808,7 +808,7 @@ class TestAuth(unittest.TestCase): 'x-forwarded-for': '127.0.0.1'}) req.remote_addr = '127.0.0.2' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) self.test_auth.app = FakeApp(iter(NO_CONTENT_RESP * 1), sync_key='secret') @@ -820,13 +820,13 @@ class TestAuth(unittest.TestCase): 'x-cluster-client-ip': '127.0.0.1'}) req.remote_addr = '127.0.0.2' resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) def test_options_call(self): req = self._make_request('/v1/AUTH_cfa/c/o', environ={'REQUEST_METHOD': 'OPTIONS'}) resp = self.test_auth.authorize(req) - self.assertEquals(resp, None) + self.assertEqual(resp, None) def test_get_user_group(self): # More tests in TestGetUserGroups class @@ -835,20 +835,20 @@ class TestAuth(unittest.TestCase): ath.users = {'test:tester': {'groups': ['.admin']}} groups = ath._get_user_groups('test', 'test:tester', 'AUTH_test') - self.assertEquals(groups, 'test,test:tester,AUTH_test') + self.assertEqual(groups, 'test,test:tester,AUTH_test') ath.users = {'test:tester': {'groups': []}} groups = ath._get_user_groups('test', 'test:tester', 'AUTH_test') - self.assertEquals(groups, 'test,test:tester') + self.assertEqual(groups, 'test,test:tester') def test_auth_scheme(self): req = self._make_request('/v1/BLAH_account', headers={'X-Auth-Token': 'BLAH_t'}) resp = req.get_response(self.test_auth) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals(resp.headers.get('Www-Authenticate'), - 'Swift realm="BLAH_account"') + self.assertEqual(resp.headers.get('Www-Authenticate'), + 'Swift realm="BLAH_account"') class TestAuthWithMultiplePrefixes(TestAuth): @@ -870,7 +870,7 @@ class TestGetUserGroups(unittest.TestCase): 'user_test_tester': 'testing .admin http://saio:8080/v1/AUTH_monkey'})(app) groups = ath._get_user_groups('test', 'test:tester', 'AUTH_monkey') - self.assertEquals(groups, 'test,test:tester,AUTH_test,AUTH_monkey') + self.assertEqual(groups, 'test,test:tester,AUTH_test,AUTH_monkey') def test_no_prefix_reseller(self): app = FakeApp() @@ -878,11 +878,11 @@ class TestGetUserGroups(unittest.TestCase): ath.users = {'test:tester': {'groups': ['.admin']}} groups = ath._get_user_groups('test', 'test:tester', 'test') - self.assertEquals(groups, 'test,test:tester') + self.assertEqual(groups, 'test,test:tester') ath.users = {'test:tester': {'groups': []}} groups = ath._get_user_groups('test', 'test:tester', 'test') - self.assertEquals(groups, 'test,test:tester') + self.assertEqual(groups, 'test,test:tester') def test_single_reseller(self): app = FakeApp() @@ -890,28 +890,28 @@ class TestGetUserGroups(unittest.TestCase): ath.users = {'test:tester': {'groups': ['.admin']}} groups = ath._get_user_groups('test', 'test:tester', 'AUTH_test') - self.assertEquals(groups, 'test,test:tester,AUTH_test') + self.assertEqual(groups, 'test,test:tester,AUTH_test') ath.users = {'test:tester': {'groups': []}} groups = ath._get_user_groups('test', 'test:tester', 'AUTH_test') - self.assertEquals(groups, 'test,test:tester') + self.assertEqual(groups, 'test,test:tester') def test_multiple_reseller(self): app = FakeApp() ath = auth.filter_factory( {'reseller_prefix': 'AUTH_, SOMEOTHER_, YETANOTHER_'})(app) - self.assertEquals(ath.reseller_prefixes, ['AUTH_', 'SOMEOTHER_', - 'YETANOTHER_']) + self.assertEqual(ath.reseller_prefixes, ['AUTH_', 'SOMEOTHER_', + 'YETANOTHER_']) ath.users = {'test:tester': {'groups': ['.admin']}} groups = ath._get_user_groups('test', 'test:tester', 'AUTH_test') - self.assertEquals(groups, - 'test,test:tester,AUTH_test,' - 'SOMEOTHER_test,YETANOTHER_test') + self.assertEqual(groups, + 'test,test:tester,AUTH_test,' + 'SOMEOTHER_test,YETANOTHER_test') ath.users = {'test:tester': {'groups': []}} groups = ath._get_user_groups('test', 'test:tester', 'AUTH_test') - self.assertEquals(groups, 'test,test:tester') + self.assertEqual(groups, 'test,test:tester') class TestDefinitiveAuth(unittest.TestCase): @@ -922,43 +922,43 @@ class TestDefinitiveAuth(unittest.TestCase): def test_noreseller_prefix(self): ath = auth.filter_factory({'reseller_prefix': ''})(FakeApp()) result = ath._is_definitive_auth(path='/v1/test') - self.assertEquals(result, False) + self.assertEqual(result, False) result = ath._is_definitive_auth(path='/v1/AUTH_test') - self.assertEquals(result, False) + self.assertEqual(result, False) result = ath._is_definitive_auth(path='/v1/BLAH_test') - self.assertEquals(result, False) + self.assertEqual(result, False) def test_blank_prefix(self): ath = auth.filter_factory({'reseller_prefix': " '', SOMEOTHER"})(FakeApp()) result = ath._is_definitive_auth(path='/v1/test') - self.assertEquals(result, False) + self.assertEqual(result, False) result = ath._is_definitive_auth(path='/v1/SOMEOTHER_test') - self.assertEquals(result, True) + self.assertEqual(result, True) result = ath._is_definitive_auth(path='/v1/SOMEOTHERtest') - self.assertEquals(result, False) + self.assertEqual(result, False) def test_default_prefix(self): ath = auth.filter_factory({})(FakeApp()) result = ath._is_definitive_auth(path='/v1/AUTH_test') - self.assertEquals(result, True) + self.assertEqual(result, True) result = ath._is_definitive_auth(path='/v1/BLAH_test') - self.assertEquals(result, False) + self.assertEqual(result, False) ath = auth.filter_factory({'reseller_prefix': 'AUTH'})(FakeApp()) result = ath._is_definitive_auth(path='/v1/AUTH_test') - self.assertEquals(result, True) + self.assertEqual(result, True) result = ath._is_definitive_auth(path='/v1/BLAH_test') - self.assertEquals(result, False) + self.assertEqual(result, False) def test_multiple_prefixes(self): ath = auth.filter_factory({'reseller_prefix': 'AUTH, SOMEOTHER'})(FakeApp()) result = ath._is_definitive_auth(path='/v1/AUTH_test') - self.assertEquals(result, True) + self.assertEqual(result, True) result = ath._is_definitive_auth(path='/v1/SOMEOTHER_test') - self.assertEquals(result, True) + self.assertEqual(result, True) result = ath._is_definitive_auth(path='/v1/BLAH_test') - self.assertEquals(result, False) + self.assertEqual(result, False) class TestParseUserCreation(unittest.TestCase): @@ -969,7 +969,7 @@ class TestParseUserCreation(unittest.TestCase): 'user_has_url': 'urlly .admin http://a.b/v1/DEF_has', 'user_admin_admin': 'admin .admin .reseller_admin', })(FakeApp()) - self.assertEquals(auth_filter.users, { + self.assertEqual(auth_filter.users, { 'admin:admin': { 'url': '$HOST/v1/ABC_admin', 'groups': ['.admin', '.reseller_admin'], @@ -997,7 +997,7 @@ class TestParseUserCreation(unittest.TestCase): b64encode('ab').rstrip('=')): 'urlly .admin http://a.b/v1/DEF_has', })(FakeApp()) - self.assertEquals(auth_filter.users, { + self.assertEqual(auth_filter.users, { 'test:tester3': { 'url': '$HOST/v1/ABC_test', 'groups': ['.reseller_admin'], @@ -1071,7 +1071,7 @@ class TestAccountAcls(unittest.TestCase): # The request returned by _make_request should be allowed resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) def test_account_acl_failures(self): test_auth = auth.filter_factory( @@ -1082,14 +1082,14 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request('/v1/%s_otheract' % self.accpre, user_groups="AUTH_bob") resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 403) + self.assertEqual(resp.status_int, 403) # If the target account has no ACLs, a non-owner shouldn't get in req = self._make_request('/v1/%s_otheract' % self.accpre, user_groups="AUTH_admin", acls={}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 403) + self.assertEqual(resp.status_int, 403) def test_admin_privileges(self): test_auth = auth.filter_factory( @@ -1105,7 +1105,7 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups="AUTH_admin", environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) # swift_owner should be set to True if method != 'OPTIONS': @@ -1122,7 +1122,7 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups="AUTH_rw", environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) # swift_owner should NOT be set to True self.assertFalse(req.environ.get('swift_owner')) @@ -1132,7 +1132,7 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups="AUTH_rw", environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 403) + self.assertEqual(resp.status_int, 403) # RW user should be able to GET, PUT, POST, or DELETE to containers # and objects @@ -1142,7 +1142,7 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups="AUTH_rw", environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) def test_readonly_privileges(self): test_auth = auth.filter_factory( @@ -1158,14 +1158,14 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups="AUTH_ro", environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) # swift_owner should NOT be set to True for the ReadOnly ACL self.assertFalse(req.environ.get('swift_owner')) for method in ('PUT', 'POST', 'DELETE'): req = self._make_request(target, user_groups="AUTH_ro", environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 403) + self.assertEqual(resp.status_int, 403) # swift_owner should NOT be set to True for the ReadOnly ACL self.assertFalse(req.environ.get('swift_owner')) @@ -1183,7 +1183,7 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups=mygroups, environ={'REQUEST_METHOD': method}) resp = req.get_response(test_auth) - self.assertEquals( + self.assertEqual( resp.status_int, 204, "%s (%s) - expected 204, got %d" % (target, method, resp.status_int)) @@ -1212,16 +1212,16 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, headers=good_headers, user_groups=user_groups) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) # syntactically valid acls should go through update = {'x-account-access-control': good_acl} req = self._make_request(target, user_groups=user_groups, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204, - 'Expected 204, got %s, response body: %s' - % (resp.status_int, resp.body)) + self.assertEqual(resp.status_int, 204, + 'Expected 204, got %s, response body: %s' + % (resp.status_int, resp.body)) # syntactically valid empty acls should go through for acl in empty_acls: @@ -1229,21 +1229,21 @@ class TestAccountAcls(unittest.TestCase): req = self._make_request(target, user_groups=user_groups, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) errmsg = 'X-Account-Access-Control invalid: %s' # syntactically invalid acls get a 400 update = {'x-account-access-control': bad_acl} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) - self.assertEquals(errmsg % "Syntax error", resp.body[:46]) + self.assertEqual(resp.status_int, 400) + self.assertEqual(errmsg % "Syntax error", resp.body[:46]) # syntactically valid acls with bad keys also get a 400 update = {'x-account-access-control': wrong_acl} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) self.assertTrue(resp.body.startswith( errmsg % "Key 'other-auth-system' not recognized"), resp.body) @@ -1251,7 +1251,7 @@ class TestAccountAcls(unittest.TestCase): update = {'x-account-access-control': bad_value_acl} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) self.assertTrue(resp.body.startswith( errmsg % "Value for key 'admin' must be a list"), resp.body) @@ -1259,7 +1259,7 @@ class TestAccountAcls(unittest.TestCase): update = {'x-account-access-control': bad_list_types} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) self.assertTrue(resp.body.startswith( errmsg % "Elements of 'read-only' list must be strings"), resp.body) @@ -1268,15 +1268,15 @@ class TestAccountAcls(unittest.TestCase): update = {'x-account-access-control': not_dict_acl} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) - self.assertEquals(errmsg % "Syntax error", resp.body[:46]) + self.assertEqual(resp.status_int, 400) + self.assertEqual(errmsg % "Syntax error", resp.body[:46]) # acls with wrong json structure also get a 400 update = {'x-account-access-control': not_dict_acl2} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) - self.assertEquals(errmsg % "Syntax error", resp.body[:46]) + self.assertEqual(resp.status_int, 400) + self.assertEqual(errmsg % "Syntax error", resp.body[:46]) def test_acls_propagate_to_sysmeta(self): test_auth = auth.filter_factory({'user_admin_user': 'testing'})( @@ -1290,14 +1290,14 @@ class TestAccountAcls(unittest.TestCase): # no acls -- no problem! req = self._make_request(target, headers=good_headers) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) self.assertEqual(None, req.headers.get(sysmeta_hdr)) # syntactically valid acls should go through update = {'x-account-access-control': good_acl} req = self._make_request(target, headers=dict(good_headers, **update)) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 204) + self.assertEqual(resp.status_int, 204) self.assertEqual(good_acl, req.headers.get(sysmeta_hdr)) def test_bad_acls_get_denied(self): @@ -1317,7 +1317,7 @@ class TestAccountAcls(unittest.TestCase): hdrs = dict(good_headers, **{'x-account-access-control': bad_acl}) req = self._make_request(target, headers=hdrs) resp = req.get_response(test_auth) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) class TestAuthMultiplePrefixes(TestAccountAcls): @@ -1337,34 +1337,34 @@ class PrefixAccount(unittest.TestCase): def test_default(self): conf = {} test_auth = auth.filter_factory(conf)(FakeApp()) - self.assertEquals(test_auth._get_account_prefix( - 'AUTH_1234'), 'AUTH_') - self.assertEquals(test_auth._get_account_prefix( - 'JUNK_1234'), None) + self.assertEqual(test_auth._get_account_prefix( + 'AUTH_1234'), 'AUTH_') + self.assertEqual(test_auth._get_account_prefix( + 'JUNK_1234'), None) def test_same_as_default(self): conf = {'reseller_prefix': 'AUTH'} test_auth = auth.filter_factory(conf)(FakeApp()) - self.assertEquals(test_auth._get_account_prefix( - 'AUTH_1234'), 'AUTH_') - self.assertEquals(test_auth._get_account_prefix( - 'JUNK_1234'), None) + self.assertEqual(test_auth._get_account_prefix( + 'AUTH_1234'), 'AUTH_') + self.assertEqual(test_auth._get_account_prefix( + 'JUNK_1234'), None) def test_blank_reseller(self): conf = {'reseller_prefix': ''} test_auth = auth.filter_factory(conf)(FakeApp()) - self.assertEquals(test_auth._get_account_prefix( - '1234'), '') - self.assertEquals(test_auth._get_account_prefix( - 'JUNK_1234'), '') # yes, it should return '' + self.assertEqual(test_auth._get_account_prefix( + '1234'), '') + self.assertEqual(test_auth._get_account_prefix( + 'JUNK_1234'), '') # yes, it should return '' def test_multiple_resellers(self): conf = {'reseller_prefix': 'AUTH, PRE2'} test_auth = auth.filter_factory(conf)(FakeApp()) - self.assertEquals(test_auth._get_account_prefix( - 'AUTH_1234'), 'AUTH_') - self.assertEquals(test_auth._get_account_prefix( - 'JUNK_1234'), None) + self.assertEqual(test_auth._get_account_prefix( + 'AUTH_1234'), 'AUTH_') + self.assertEqual(test_auth._get_account_prefix( + 'JUNK_1234'), None) class ServiceTokenFunctionality(unittest.TestCase): diff --git a/test/unit/common/middleware/test_tempurl.py b/test/unit/common/middleware/test_tempurl.py index 00f0af1d71..170736751a 100644 --- a/test/unit/common/middleware/test_tempurl.py +++ b/test/unit/common/middleware/test_tempurl.py @@ -112,7 +112,7 @@ class TestTempURL(unittest.TestCase): def test_passthrough(self): resp = self._make_request('/v1/a/c/o').get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' not in resp.body) def test_allow_options(self): @@ -120,7 +120,7 @@ class TestTempURL(unittest.TestCase): resp = self._make_request( '/v1/a/c/o?temp_url_sig=abcde&temp_url_expires=12345', environ={'REQUEST_METHOD': 'OPTIONS'}).get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) def assert_valid_sig(self, expires, path, keys, sig, environ=None): if not environ: @@ -130,11 +130,11 @@ class TestTempURL(unittest.TestCase): req = self._make_request(path, keys=keys, environ=environ) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], - 'attachment; filename="o"; ' + "filename*=UTF-8''o") - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], + 'attachment; filename="o"; ' + "filename*=UTF-8''o") + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_get_valid(self): method = 'GET' @@ -192,12 +192,12 @@ class TestTempURL(unittest.TestCase): 'filename=bob%%20%%22killer%%22.txt' % (sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], - 'attachment; filename="bob %22killer%22.txt"; ' + - "filename*=UTF-8''bob%20%22killer%22.txt") - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], + 'attachment; filename="bob %22killer%22.txt"; ' + + "filename*=UTF-8''bob%20%22killer%22.txt") + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_head_valid(self): method = 'HEAD' @@ -212,7 +212,7 @@ class TestTempURL(unittest.TestCase): % (sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) def test_get_valid_with_filename_and_inline(self): method = 'GET' @@ -226,10 +226,10 @@ class TestTempURL(unittest.TestCase): 'filename=bob%%20%%22killer%%22.txt&inline=' % (sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], 'inline') - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], 'inline') + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_get_valid_with_inline(self): method = 'GET' @@ -243,10 +243,10 @@ class TestTempURL(unittest.TestCase): 'inline=' % (sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], 'inline') - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], 'inline') + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_obj_odd_chars(self): method = 'GET' @@ -260,12 +260,12 @@ class TestTempURL(unittest.TestCase): sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], - 'attachment; filename="a%0D%0Ab"; ' + - "filename*=UTF-8''a%0D%0Ab") - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], + 'attachment; filename="a%0D%0Ab"; ' + + "filename*=UTF-8''a%0D%0Ab") + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_obj_odd_chars_in_content_disposition_metadata(self): method = 'GET' @@ -280,11 +280,11 @@ class TestTempURL(unittest.TestCase): headers = [('Content-Disposition', 'attachment; filename="fu\nbar"')] self.tempurl.app = FakeApp(iter([('200 Ok', headers, '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], - 'attachment; filename="fu%0Abar"') - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], + 'attachment; filename="fu%0Abar"') + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_obj_trailing_slash(self): method = 'GET' @@ -298,12 +298,12 @@ class TestTempURL(unittest.TestCase): sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.headers['content-disposition'], - 'attachment; filename="o"; ' + - "filename*=UTF-8''o") - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], + 'attachment; filename="o"; ' + + "filename*=UTF-8''o") + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_filename_trailing_slash(self): method = 'GET' @@ -317,13 +317,13 @@ class TestTempURL(unittest.TestCase): 'filename=/i/want/this/just/as/it/is/' % (sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) - self.assertEquals( + self.assertEqual(resp.status_int, 200) + self.assertEqual( resp.headers['content-disposition'], 'attachment; filename="/i/want/this/just/as/it/is/"; ' + "filename*=UTF-8''/i/want/this/just/as/it/is/") - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_get_valid_but_404(self): method = 'GET' @@ -337,10 +337,10 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertFalse('content-disposition' in resp.headers) - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_put_not_allowed_by_get(self): method = 'GET' @@ -355,7 +355,7 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -372,9 +372,9 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 404) + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_get_not_allowed_by_put(self): method = 'PUT' @@ -388,7 +388,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -403,7 +403,7 @@ class TestTempURL(unittest.TestCase): path, keys=[key], environ={'QUERY_STRING': 'temp_url_expires=%s' % expires}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -418,7 +418,7 @@ class TestTempURL(unittest.TestCase): path, keys=[key], environ={'QUERY_STRING': 'temp_url_sig=%s' % sig}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -434,7 +434,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -450,7 +450,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -467,9 +467,9 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 404) + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_head_allowed_by_put(self): method = 'PUT' @@ -484,9 +484,9 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 404) + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_head_allowed_by_post(self): method = 'POST' @@ -501,9 +501,9 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) - self.assertEquals(req.environ['swift.authorize_override'], True) - self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl') + self.assertEqual(resp.status_int, 404) + self.assertEqual(req.environ['swift.authorize_override'], True) + self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') def test_head_otherwise_not_allowed(self): method = 'PUT' @@ -521,7 +521,7 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) def test_post_when_forbidden_by_config(self): @@ -538,7 +538,7 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -556,7 +556,7 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -573,7 +573,7 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) def test_unknown_not_allowed(self): method = 'UNKNOWN' @@ -588,7 +588,7 @@ class TestTempURL(unittest.TestCase): 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -615,7 +615,7 @@ class TestTempURL(unittest.TestCase): # make request will setup the environ cache for us req = self._make_request(path + qs, **key_kwargs) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) # sanity check + self.assertEqual(resp.status_int, 404) # sanity check authorize = req.environ['swift.authorize'] # Requests for other objects happen if, for example, you're @@ -636,7 +636,7 @@ class TestTempURL(unittest.TestCase): req = self._make_request(path + qs, **key_kwargs) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) # sanity check + self.assertEqual(resp.status_int, 404) # sanity check authorize = req.environ['swift.authorize'] oo_resp = authorize(req_other_object) @@ -657,7 +657,7 @@ class TestTempURL(unittest.TestCase): req = self._make_request(path + qs, **key_kwargs) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) # sanity check + self.assertEqual(resp.status_int, 404) # sanity check authorize = req.environ['swift.authorize'] oo_resp = authorize(req_other_object) @@ -679,7 +679,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -699,7 +699,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -715,7 +715,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires + 1)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -731,7 +731,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) @@ -749,7 +749,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 400) + self.assertEqual(resp.status_int, 400) self.assertTrue('header' in resp.body) self.assertTrue('not allowed' in resp.body) self.assertTrue('X-Object-Manifest' in resp.body) @@ -769,7 +769,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('x-remove-this' not in self.app.request.headers) def test_removed_incoming_headers_match(self): @@ -789,9 +789,9 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('x-remove-this-one' not in self.app.request.headers) - self.assertEquals( + self.assertEqual( self.app.request.headers['x-remove-this-except-this'], 'value2') def test_allow_trumps_incoming_header_conflict(self): @@ -810,7 +810,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('x-conflict-header' in self.app.request.headers) def test_allow_trumps_incoming_header_startswith_conflict(self): @@ -829,7 +829,7 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('x-conflict-header-test' in self.app.request.headers) def test_removed_outgoing_header(self): @@ -846,9 +846,9 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) self.assertTrue('x-test-header-one-a' not in resp.headers) - self.assertEquals(resp.headers['x-test-header-two-a'], 'value2') + self.assertEqual(resp.headers['x-test-header-two-a'], 'value2') def test_removed_outgoing_headers_match(self): self.tempurl = tempurl.filter_factory({ @@ -865,10 +865,10 @@ class TestTempURL(unittest.TestCase): environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( sig, expires)}) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 404) - self.assertEquals(resp.headers['x-test-header-one-a'], 'value1') + self.assertEqual(resp.status_int, 404) + self.assertEqual(resp.headers['x-test-header-one-a'], 'value1') self.assertTrue('x-test-header-two-a' not in resp.headers) - self.assertEquals(resp.headers['x-test-header-two-b'], 'value3') + self.assertEqual(resp.headers['x-test-header-two-b'], 'value3') def test_allow_trumps_outgoing_header_conflict(self): self.tempurl = tempurl.filter_factory({ @@ -888,7 +888,7 @@ class TestTempURL(unittest.TestCase): self.tempurl.app = FakeApp(iter([('200 Ok', { 'X-Conflict-Header': 'value'}, '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertTrue('x-conflict-header' in resp.headers) self.assertEqual(resp.headers['x-conflict-header'], 'value') @@ -910,96 +910,96 @@ class TestTempURL(unittest.TestCase): self.tempurl.app = FakeApp(iter([('200 Ok', { 'X-Conflict-Header-Test': 'value'}, '123')])) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 200) + self.assertEqual(resp.status_int, 200) self.assertTrue('x-conflict-header-test' in resp.headers) self.assertEqual(resp.headers['x-conflict-header-test'], 'value') def test_get_account_and_container(self): - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'HEAD', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c')) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c')) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c')) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c')) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'DELETE', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c')) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'UNKNOWN', 'PATH_INFO': '/v1/a/c/o'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c/'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c//////'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c///o///'}), ('a', 'c')) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a//o'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1//c/o'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '//a/c/o'}), (None, None)) - self.assertEquals(self.tempurl._get_account_and_container({ + self.assertEqual(self.tempurl._get_account_and_container({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v2/a/c/o'}), (None, None)) def test_get_temp_url_info(self): s = 'f5d5051bddf5df7e27c628818738334f' e = int(time() + 86400) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( s, e)}), (s, e, None, None)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&' 'filename=bobisyouruncle' % (s, e)}), (s, e, 'bobisyouruncle', None)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info({}), (None, None, None, None)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_expires=%s' % e}), (None, e, None, None)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s' % s}), (s, None, None, None)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=bad' % ( s)}), (s, 0, None, None)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&' 'inline=' % (s, e)}), (s, e, None, True)) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&' 'filename=bobisyouruncle&inline=' % (s, e)}), (s, e, 'bobisyouruncle', True)) e = int(time() - 1) - self.assertEquals( + self.assertEqual( self.tempurl._get_temp_url_info( {'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % ( s, e)}), (s, 0, None, None)) def test_get_hmacs(self): - self.assertEquals( + self.assertEqual( self.tempurl._get_hmacs( {'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c/o'}, 1, [('abc', 'account')]), [('026d7f7cc25256450423c7ad03fc9f5ffc1dab6d', 'account')]) - self.assertEquals( + self.assertEqual( self.tempurl._get_hmacs( {'REQUEST_METHOD': 'HEAD', 'PATH_INFO': '/v1/a/c/o'}, 1, [('abc', 'account')], request_method='GET'), @@ -1013,7 +1013,7 @@ class TestTempURL(unittest.TestCase): self.assertTrue('Temp URL invalid' in ''.join( self.tempurl._invalid({'REQUEST_METHOD': 'GET'}, _start_response))) - self.assertEquals('', ''.join( + self.assertEqual('', ''.join( self.tempurl._invalid({'REQUEST_METHOD': 'HEAD'}, _start_response))) @@ -1022,7 +1022,7 @@ class TestTempURL(unittest.TestCase): environ = {} resp = self._make_request('/v1/a/c/o', environ=environ).get_response( self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' not in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) self.assertTrue('swift.auth_scheme' not in environ) @@ -1034,7 +1034,7 @@ class TestTempURL(unittest.TestCase): req = self._make_request('/v1/a/c/o', keys=['abc'], environ=environ) resp = req.get_response(self.tempurl) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Temp URL invalid' in resp.body) self.assertTrue('Www-Authenticate' in resp.headers) diff --git a/test/unit/common/middleware/test_versioned_writes.py b/test/unit/common/middleware/test_versioned_writes.py index 52cb6fd44b..5f891031ba 100644 --- a/test/unit/common/middleware/test_versioned_writes.py +++ b/test/unit/common/middleware/test_versioned_writes.py @@ -88,13 +88,13 @@ class VersionedWritesTestCase(unittest.TestCase): headers={'X-Versions-Location': 'ver_cont'}, environ={'REQUEST_METHOD': 'PUT'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') # check for sysmeta header calls = self.app.calls_with_headers method, path, req_headers = calls[0] - self.assertEquals('PUT', method) - self.assertEquals('/v1/a/c', path) + self.assertEqual('PUT', method) + self.assertEqual('/v1/a/c', path) self.assertTrue('x-container-sysmeta-versions-location' in req_headers) self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -109,7 +109,7 @@ class VersionedWritesTestCase(unittest.TestCase): headers={'X-Versions-Location': 'ver_cont'}, environ={'REQUEST_METHOD': method}) status, headers, body = self.call_vw(req) - self.assertEquals(status, "412 Precondition Failed") + self.assertEqual(status, "412 Precondition Failed") # GET/HEAD performs as normal self.app.register('GET', '/v1/a/c', swob.HTTPOk, {}, 'passed') @@ -120,7 +120,7 @@ class VersionedWritesTestCase(unittest.TestCase): headers={'X-Versions-Location': 'ver_cont'}, environ={'REQUEST_METHOD': method}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') def test_remove_versions_location(self): self.app.register('POST', '/v1/a/c', swob.HTTPOk, {}, 'passed') @@ -128,13 +128,13 @@ class VersionedWritesTestCase(unittest.TestCase): headers={'X-Remove-Versions-Location': 'x'}, environ={'REQUEST_METHOD': 'POST'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') # check for sysmeta header calls = self.app.calls_with_headers method, path, req_headers = calls[0] - self.assertEquals('POST', method) - self.assertEquals('/v1/a/c', path) + self.assertEqual('POST', method) + self.assertEqual('/v1/a/c', path) self.assertTrue('x-container-sysmeta-versions-location' in req_headers) self.assertTrue('x-versions-location' in req_headers) self.assertEqual(len(self.authorized), 1) @@ -151,14 +151,14 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'POST'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertTrue(('X-Versions-Location', 'ver_cont') in headers) # check for sysmeta header calls = self.app.calls_with_headers method, path, req_headers = calls[0] - self.assertEquals('POST', method) - self.assertEquals('/v1/a/c', path) + self.assertEqual('POST', method) + self.assertEqual('/v1/a/c', path) self.assertTrue('x-container-sysmeta-versions-location' in req_headers) self.assertTrue('x-remove-versions-location' not in req_headers) self.assertEqual(len(self.authorized), 1) @@ -172,7 +172,7 @@ class VersionedWritesTestCase(unittest.TestCase): '/v1/a/c', environ={'REQUEST_METHOD': 'GET'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertTrue(('X-Versions-Location', 'ver_cont') in headers) self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -183,7 +183,7 @@ class VersionedWritesTestCase(unittest.TestCase): '/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -192,7 +192,7 @@ class VersionedWritesTestCase(unittest.TestCase): '/v1/a/c/o', environ={'REQUEST_METHOD': 'HEAD'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -206,7 +206,7 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -222,7 +222,7 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -238,16 +238,16 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') # check for 'X-Backend-Storage-Policy-Index' in HEAD request calls = self.app.calls_with_headers method, path, req_headers = calls[0] - self.assertEquals('HEAD', method) - self.assertEquals('/v1/a/c/o', path) + self.assertEqual('HEAD', method) + self.assertEqual('/v1/a/c/o', path) self.assertTrue('X-Backend-Storage-Policy-Index' in req_headers) - self.assertEquals('2', - req_headers.get('X-Backend-Storage-Policy-Index')) + self.assertEqual('2', + req_headers.get('X-Backend-Storage-Policy-Index')) self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -265,7 +265,7 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '201 Created') + self.assertEqual(status, '201 Created') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) called_method = [method for (method, path, hdrs) in self.app._calls] @@ -282,7 +282,7 @@ class VersionedWritesTestCase(unittest.TestCase): '/v1/a/c/o', environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '204 No Content') + self.assertEqual(status, '204 No Content') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) called_method = \ @@ -301,13 +301,13 @@ class VersionedWritesTestCase(unittest.TestCase): '/v1/a/c/o', environ={'REQUEST_METHOD': 'COPY', 'swift.cache': cache}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '201 Created') + self.assertEqual(status, '201 Created') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) called_method = \ [method for (method, path, rheaders) in self.app._calls] self.assertTrue('COPY' in called_method) - self.assertEquals(called_method.count('COPY'), 1) + self.assertEqual(called_method.count('COPY'), 1) def test_new_version_success(self): self.app.register( @@ -323,7 +323,7 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -345,15 +345,15 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache, 'CONTENT_LENGTH': '100'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) # check that sysmeta header was used calls = self.app.calls_with_headers method, path, req_headers = calls[1] - self.assertEquals('COPY', method) - self.assertEquals('/v1/a/c/o', path) + self.assertEqual('COPY', method) + self.assertEqual('/v1/a/c/o', path) self.assertTrue(req_headers['Destination'].startswith('ver_cont/')) def test_copy_first_version(self): @@ -368,7 +368,7 @@ class VersionedWritesTestCase(unittest.TestCase): 'CONTENT_LENGTH': '100'}, headers={'Destination': 'tgt_cont/tgt_obj'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -387,7 +387,7 @@ class VersionedWritesTestCase(unittest.TestCase): 'CONTENT_LENGTH': '100'}, headers={'Destination': 'tgt_cont/tgt_obj'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -407,7 +407,7 @@ class VersionedWritesTestCase(unittest.TestCase): headers={'Destination': 'tgt_cont/tgt_obj', 'Destination-Account': 'tgt_a'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -420,7 +420,7 @@ class VersionedWritesTestCase(unittest.TestCase): headers={'Destination': 'tgt_cont/tgt_obj', 'Destination-Account': '/im/on/a/boat'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '412 Precondition Failed') + self.assertEqual(status, '412 Precondition Failed') def test_delete_first_object_success(self): self.app.register( @@ -435,7 +435,7 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache, 'CONTENT_LENGTH': '0'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -473,14 +473,14 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache, 'CONTENT_LENGTH': '0'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) # check that X-If-Delete-At was removed from DELETE request calls = self.app.calls_with_headers method, path, req_headers = calls.pop() - self.assertEquals('DELETE', method) + self.assertEqual('DELETE', method) self.assertTrue(path.startswith('/v1/a/ver_cont/001o/2')) self.assertFalse('x-if-delete-at' in req_headers or 'X-If-Delete-At' in req_headers) @@ -521,7 +521,7 @@ class VersionedWritesTestCase(unittest.TestCase): environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache, 'CONTENT_LENGTH': '0'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '200 OK') + self.assertEqual(status, '200 OK') self.assertEqual(len(self.authorized), 1) self.assertRequestEqual(req, self.authorized[0]) @@ -561,6 +561,6 @@ class VersionedWritesTestCase(unittest.TestCase): 'swift.authorize': fake_authorize, 'CONTENT_LENGTH': '0'}) status, headers, body = self.call_vw(req) - self.assertEquals(status, '403 Forbidden') + self.assertEqual(status, '403 Forbidden') self.assertEqual(len(authorize_call), 1) self.assertRequestEqual(req, authorize_call[0]) diff --git a/test/unit/common/middleware/test_xprofile.py b/test/unit/common/middleware/test_xprofile.py index b98fdb8a04..7296f69211 100644 --- a/test/unit/common/middleware/test_xprofile.py +++ b/test/unit/common/middleware/test_xprofile.py @@ -220,8 +220,8 @@ class Test_profile_log(unittest.TestCase): shutil.rmtree(self.dir2, ignore_errors=True) def test_get_all_pids(self): - self.assertEquals(self.profile_log1.get_all_pids(), - sorted(self.pids1, reverse=True)) + self.assertEqual(self.profile_log1.get_all_pids(), + sorted(self.pids1, reverse=True)) for pid in self.profile_log2.get_all_pids(): self.assertTrue(pid.split('-')[0] in self.pids2) @@ -247,18 +247,18 @@ class Test_profile_log(unittest.TestCase): def test_get_logfiles(self): log_files = self.profile_log1.get_logfiles('all') self.assertEqual(len(log_files), 3) - self.assertEquals(len(log_files), len(self.pids1)) + self.assertEqual(len(log_files), len(self.pids1)) log_files = self.profile_log1.get_logfiles('current') self.assertEqual(len(log_files), 1) - self.assertEquals(log_files, [self.log_filename_prefix1 - + str(os.getpid())]) + self.assertEqual(log_files, [self.log_filename_prefix1 + + str(os.getpid())]) log_files = self.profile_log1.get_logfiles(self.pids1[0]) self.assertEqual(len(log_files), 1) - self.assertEquals(log_files, [self.log_filename_prefix1 - + self.pids1[0]]) + self.assertEqual(log_files, [self.log_filename_prefix1 + + self.pids1[0]]) log_files = self.profile_log2.get_logfiles('all') self.assertEqual(len(log_files), 3) - self.assertEquals(len(log_files), len(self.pids2)) + self.assertEqual(len(log_files), len(self.pids2)) log_files = self.profile_log2.get_logfiles('current') self.assertEqual(len(log_files), 1) self.assertTrue(log_files[0].find(self.log_filename_prefix2 + diff --git a/test/unit/common/ring/test_builder.py b/test/unit/common/ring/test_builder.py index 2ca8a9b620..c11b7220c7 100644 --- a/test/unit/common/ring/test_builder.py +++ b/test/unit/common/ring/test_builder.py @@ -62,13 +62,13 @@ class TestRingBuilder(unittest.TestCase): def test_init(self): rb = ring.RingBuilder(8, 3, 1) - self.assertEquals(rb.part_power, 8) - self.assertEquals(rb.replicas, 3) - self.assertEquals(rb.min_part_hours, 1) - self.assertEquals(rb.parts, 2 ** 8) - self.assertEquals(rb.devs, []) - self.assertEquals(rb.devs_changed, False) - self.assertEquals(rb.version, 0) + self.assertEqual(rb.part_power, 8) + self.assertEqual(rb.replicas, 3) + self.assertEqual(rb.min_part_hours, 1) + self.assertEqual(rb.parts, 2 ** 8) + self.assertEqual(rb.devs, []) + self.assertEqual(rb.devs_changed, False) + self.assertEqual(rb.version, 0) def test_overlarge_part_powers(self): ring.RingBuilder(32, 3, 1) # passes by not crashing @@ -166,7 +166,7 @@ class TestRingBuilder(unittest.TestCase): self.assertFalse(rb0.get_ring() is r0) self.assertNotEquals(r0.to_dict(), r1.to_dict()) - self.assertEquals(r1.to_dict(), r2.to_dict()) + self.assertEqual(r1.to_dict(), r2.to_dict()) def test_rebalance_part_on_deleted_other_part_on_drained(self): rb = ring.RingBuilder(8, 3, 1) @@ -216,12 +216,12 @@ class TestRingBuilder(unittest.TestCase): # test add new dev with no id dev_id = rb.add_dev({'zone': 0, 'region': 1, 'weight': 1, 'ip': '127.0.0.1', 'port': 6000}) - self.assertEquals(rb.devs[0]['id'], 0) + self.assertEqual(rb.devs[0]['id'], 0) self.assertEqual(dev_id, 0) # test add another dev with no id dev_id = rb.add_dev({'zone': 3, 'region': 2, 'weight': 1, 'ip': '127.0.0.1', 'port': 6000}) - self.assertEquals(rb.devs[1]['id'], 1) + self.assertEqual(rb.devs[1]['id'], 1) self.assertEqual(dev_id, 1) def test_set_dev_weight(self): @@ -240,7 +240,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 128, 1: 128, 2: 256, 3: 256}) + self.assertEqual(counts, {0: 128, 1: 128, 2: 256, 3: 256}) rb.set_dev_weight(0, 0.75) rb.set_dev_weight(1, 0.25) rb.pretend_min_part_hours_passed() @@ -250,7 +250,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 192, 1: 64, 2: 256, 3: 256}) + self.assertEqual(counts, {0: 192, 1: 64, 2: 256, 3: 256}) def test_remove_dev(self): rb = ring.RingBuilder(8, 3, 1) @@ -268,7 +268,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 192, 1: 192, 2: 192, 3: 192}) + self.assertEqual(counts, {0: 192, 1: 192, 2: 192, 3: 192}) rb.remove_dev(1) rb.pretend_min_part_hours_passed() rb.rebalance() @@ -277,7 +277,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 256, 2: 256, 3: 256}) + self.assertEqual(counts, {0: 256, 2: 256, 3: 256}) def test_remove_a_lot(self): rb = ring.RingBuilder(3, 3, 1) @@ -515,7 +515,7 @@ class TestRingBuilder(unittest.TestCase): counts['zone'][dev['zone']] += 1 counts['dev_id'][dev['id']] += 1 - self.assertEquals(8, sum(counts['zone'].values())) + self.assertEqual(8, sum(counts['zone'].values())) for zone, replica_count in counts['zone'].items(): if replica_count not in (2, 3): raise AssertionError( @@ -572,7 +572,7 @@ class TestRingBuilder(unittest.TestCase): counts['zone'][dev['zone']] += 1 counts['dev_id'][dev['id']] += 1 - self.assertEquals({0: 2, 1: 2, 2: 2}, dict(counts['zone'])) + self.assertEqual({0: 2, 1: 2, 2: 2}, dict(counts['zone'])) # each part is assigned once to six unique devices self.assertEqual((counts['dev_id'].values()), [1] * 6) self.assertEqual(len(set(counts['dev_id'].keys())), 6) @@ -686,7 +686,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 256, 1: 256, 2: 256}) + self.assertEqual(counts, {0: 256, 1: 256, 2: 256}) rb.add_dev({'id': 3, 'region': 0, 'zone': 3, 'weight': 1, 'ip': '127.0.0.1', 'port': 10003, 'device': 'sda1'}) rb.pretend_min_part_hours_passed() @@ -696,7 +696,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 192, 1: 192, 2: 192, 3: 192}) + self.assertEqual(counts, {0: 192, 1: 192, 2: 192, 3: 192}) rb.set_dev_weight(3, 100) rb.rebalance() r = rb.get_ring() @@ -704,7 +704,7 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts[3], 256) + self.assertEqual(counts[3], 256) def test_add_rebalance_add_rebalance_delete_rebalance(self): # Test for https://bugs.launchpad.net/swift/+bug/845952 @@ -822,8 +822,8 @@ class TestRingBuilder(unittest.TestCase): rb.rebalance(seed=2) population_by_region = self._get_population_by_region(rb) - self.assertEquals(population_by_region, - {0: 192, 1: 192, 2: 192, 3: 192}) + self.assertEqual(population_by_region, + {0: 192, 1: 192, 2: 192, 3: 192}) def test_region_fullness_with_unbalanceable_ring(self): rb = ring.RingBuilder(8, 3, 1) @@ -839,7 +839,7 @@ class TestRingBuilder(unittest.TestCase): rb.rebalance(seed=2) population_by_region = self._get_population_by_region(rb) - self.assertEquals(population_by_region, {0: 512, 1: 256}) + self.assertEqual(population_by_region, {0: 512, 1: 256}) def test_adding_region_slowly_with_unbalanceable_ring(self): rb = ring.RingBuilder(8, 3, 1) @@ -873,7 +873,7 @@ class TestRingBuilder(unittest.TestCase): # in it, so only 86 assignments occur in r1 (that's ~1/5 of the total, # since r1 has 1/5 of the weight). population_by_region = self._get_population_by_region(rb) - self.assertEquals(population_by_region, {0: 682, 1: 86}) + self.assertEqual(population_by_region, {0: 682, 1: 86}) # only 86 parts *should* move (to the new region) but randomly some # parts will flop around devices in the original region too @@ -885,7 +885,7 @@ class TestRingBuilder(unittest.TestCase): rb.rebalance(seed=2) rb.validate() population_by_region = self._get_population_by_region(rb) - self.assertEquals(population_by_region, {0: 682, 1: 86}) + self.assertEqual(population_by_region, {0: 682, 1: 86}) # after you add more weight, more partition assignments move rb.set_dev_weight(2, 0.5) @@ -894,7 +894,7 @@ class TestRingBuilder(unittest.TestCase): rb.rebalance(seed=2) rb.validate() population_by_region = self._get_population_by_region(rb) - self.assertEquals(population_by_region, {0: 614, 1: 154}) + self.assertEqual(population_by_region, {0: 614, 1: 154}) rb.set_dev_weight(2, 1.0) rb.set_dev_weight(3, 1.0) @@ -902,7 +902,7 @@ class TestRingBuilder(unittest.TestCase): rb.rebalance(seed=2) rb.validate() population_by_region = self._get_population_by_region(rb) - self.assertEquals(population_by_region, {0: 512, 1: 256}) + self.assertEqual(population_by_region, {0: 512, 1: 256}) def test_avoid_tier_change_new_region(self): rb = ring.RingBuilder(8, 3, 1) @@ -1088,12 +1088,12 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 96, 1: 96, - 2: 32, 3: 32, - 4: 96, 5: 96, - 6: 32, 7: 32, - 8: 96, 9: 96, - 10: 32, 11: 32}) + self.assertEqual(counts, {0: 96, 1: 96, + 2: 32, 3: 32, + 4: 96, 5: 96, + 6: 32, 7: 32, + 8: 96, 9: 96, + 10: 32, 11: 32}) rb.replicas *= 2 rb.rebalance(seed=1) @@ -1103,12 +1103,12 @@ class TestRingBuilder(unittest.TestCase): for part2dev_id in r._replica2part2dev_id: for dev_id in part2dev_id: counts[dev_id] = counts.get(dev_id, 0) + 1 - self.assertEquals(counts, {0: 192, 1: 192, - 2: 64, 3: 64, - 4: 192, 5: 192, - 6: 64, 7: 64, - 8: 192, 9: 192, - 10: 64, 11: 64}) + self.assertEqual(counts, {0: 192, 1: 192, + 2: 64, 3: 64, + 4: 192, 5: 192, + 6: 64, 7: 64, + 8: 192, 9: 192, + 10: 64, 11: 64}) def test_overload(self): rb = ring.RingBuilder(8, 3, 1) @@ -1459,9 +1459,9 @@ class TestRingBuilder(unittest.TestCase): fake_pickle = mock.Mock(return_value=rb) pickle.load = fake_pickle builder = ring.RingBuilder.load('fake.builder', open=fake_open) - self.assertEquals(fake_pickle.call_count, 1) + self.assertEqual(fake_pickle.call_count, 1) fake_open.assert_has_calls([mock.call('fake.builder', 'rb')]) - self.assertEquals(builder, rb) + self.assertEqual(builder, rb) fake_pickle.reset_mock() # test old style builder @@ -1469,7 +1469,7 @@ class TestRingBuilder(unittest.TestCase): pickle.load = fake_pickle builder = ring.RingBuilder.load('fake.builder', open=fake_open) fake_open.assert_has_calls([mock.call('fake.builder', 'rb')]) - self.assertEquals(builder.devs, rb.devs) + self.assertEqual(builder.devs, rb.devs) fake_pickle.reset_mock() # test old devs but no meta @@ -1480,7 +1480,7 @@ class TestRingBuilder(unittest.TestCase): pickle.load = fake_pickle builder = ring.RingBuilder.load('fake.builder', open=fake_open) fake_open.assert_has_calls([mock.call('fake.builder', 'rb')]) - self.assertEquals(builder.devs, rb.devs) + self.assertEqual(builder.devs, rb.devs) # test an empty builder fake_pickle.side_effect = EOFError @@ -1549,8 +1549,8 @@ class TestRingBuilder(unittest.TestCase): rb.save(builder_file) loaded_rb = ring.RingBuilder.load(builder_file) self.maxDiff = None - self.assertEquals(loaded_rb.to_dict(), rb.to_dict()) - self.assertEquals(loaded_rb.overload, 3.14159) + self.assertEqual(loaded_rb.to_dict(), rb.to_dict()) + self.assertEqual(loaded_rb.overload, 3.14159) @mock.patch('six.moves.builtins.open', autospec=True) @mock.patch('swift.common.ring.builder.pickle.dump', autospec=True) @@ -1607,32 +1607,32 @@ class TestRingBuilder(unittest.TestCase): rb.add_dev(d) rb.rebalance() res = rb.search_devs({'region': 0}) - self.assertEquals(res, [devs[0], devs[1]]) + self.assertEqual(res, [devs[0], devs[1]]) res = rb.search_devs({'region': 1}) - self.assertEquals(res, [devs[2], devs[3]]) + self.assertEqual(res, [devs[2], devs[3]]) res = rb.search_devs({'region': 1, 'zone': 2}) - self.assertEquals(res, [devs[2]]) + self.assertEqual(res, [devs[2]]) res = rb.search_devs({'id': 1}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) res = rb.search_devs({'zone': 1}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) res = rb.search_devs({'ip': '127.0.0.1'}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) res = rb.search_devs({'ip': '127.0.0.1', 'port': 10001}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) res = rb.search_devs({'port': 10001}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) res = rb.search_devs({'replication_ip': '127.0.0.10'}) - self.assertEquals(res, [devs[4]]) + self.assertEqual(res, [devs[4]]) res = rb.search_devs({'replication_ip': '127.0.0.10', 'replication_port': 20000}) - self.assertEquals(res, [devs[4]]) + self.assertEqual(res, [devs[4]]) res = rb.search_devs({'replication_port': 20000}) - self.assertEquals(res, [devs[4]]) + self.assertEqual(res, [devs[4]]) res = rb.search_devs({'device': 'sdb1'}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) res = rb.search_devs({'meta': 'meta1'}) - self.assertEquals(res, [devs[1]]) + self.assertEqual(res, [devs[1]]) def test_validate(self): rb = ring.RingBuilder(8, 3, 1) @@ -1674,24 +1674,24 @@ class TestRingBuilder(unittest.TestCase): rb.rebalance() counts = self._partition_counts(rb, key='zone') - self.assertEquals(counts, {0: 128, 1: 128, 2: 256, 3: 256}) + self.assertEqual(counts, {0: 128, 1: 128, 2: 256, 3: 256}) dev_usage, worst = rb.validate() self.assertTrue(dev_usage is None) self.assertTrue(worst is None) dev_usage, worst = rb.validate(stats=True) - self.assertEquals(list(dev_usage), [32, 32, 64, 64, - 32, 32, 32, # added zone0 - 32, 32, 32, # added zone1 - 64, 64, 64, # added zone2 - 64, 64, 64, # added zone3 - ]) - self.assertEquals(int(worst), 0) + self.assertEqual(list(dev_usage), [32, 32, 64, 64, + 32, 32, 32, # added zone0 + 32, 32, 32, # added zone1 + 64, 64, 64, # added zone2 + 64, 64, 64, # added zone3 + ]) + self.assertEqual(int(worst), 0) rb.set_dev_weight(2, 0) rb.rebalance() - self.assertEquals(rb.validate(stats=True)[1], MAX_BALANCE) + self.assertEqual(rb.validate(stats=True)[1], MAX_BALANCE) # Test not all partitions doubly accounted for rb.devs[1]['parts'] -= 1 diff --git a/test/unit/common/ring/test_ring.py b/test/unit/common/ring/test_ring.py index 3fbdd2538e..74ce316972 100644 --- a/test/unit/common/ring/test_ring.py +++ b/test/unit/common/ring/test_ring.py @@ -54,10 +54,10 @@ class TestRingData(unittest.TestCase): rmtree(self.testdir, ignore_errors=1) def assert_ring_data_equal(self, rd_expected, rd_got): - self.assertEquals(rd_expected._replica2part2dev_id, - rd_got._replica2part2dev_id) - self.assertEquals(rd_expected.devs, rd_got.devs) - self.assertEquals(rd_expected._part_shift, rd_got._part_shift) + self.assertEqual(rd_expected._replica2part2dev_id, + rd_got._replica2part2dev_id) + self.assertEqual(rd_expected.devs, rd_got.devs) + self.assertEqual(rd_expected._part_shift, rd_got._part_shift) def test_attrs(self): r2p2d = [[0, 1, 0, 1], [0, 1, 0, 1]] @@ -65,9 +65,9 @@ class TestRingData(unittest.TestCase): {'id': 1, 'zone': 1, 'region': 1, 'ip': '10.1.1.1', 'port': 7000}] s = 30 rd = ring.RingData(r2p2d, d, s) - self.assertEquals(rd._replica2part2dev_id, r2p2d) - self.assertEquals(rd.devs, d) - self.assertEquals(rd._part_shift, s) + self.assertEqual(rd._replica2part2dev_id, r2p2d) + self.assertEqual(rd.devs, d) + self.assertEqual(rd._part_shift, s) def test_can_load_pickled_ring_data(self): rd = ring.RingData( @@ -180,12 +180,12 @@ class TestRing(TestRingBase): rmtree(self.testdir, ignore_errors=1) def test_creation(self): - self.assertEquals(self.ring._replica2part2dev_id, - self.intended_replica2part2dev_id) - self.assertEquals(self.ring._part_shift, self.intended_part_shift) - self.assertEquals(self.ring.devs, self.intended_devs) - self.assertEquals(self.ring.reload_time, self.intended_reload_time) - self.assertEquals(self.ring.serialized_path, self.testgz) + self.assertEqual(self.ring._replica2part2dev_id, + self.intended_replica2part2dev_id) + self.assertEqual(self.ring._part_shift, self.intended_part_shift) + self.assertEqual(self.ring.devs, self.intended_devs) + self.assertEqual(self.ring.reload_time, self.intended_reload_time) + self.assertEqual(self.ring.serialized_path, self.testgz) # test invalid endcap _orig_hash_path_suffix = utils.HASH_PATH_SUFFIX _orig_hash_path_prefix = utils.HASH_PATH_PREFIX @@ -201,16 +201,16 @@ class TestRing(TestRingBase): utils.SWIFT_CONF_FILE = _orig_swift_conf_file def test_has_changed(self): - self.assertEquals(self.ring.has_changed(), False) + self.assertEqual(self.ring.has_changed(), False) os.utime(self.testgz, (time() + 60, time() + 60)) - self.assertEquals(self.ring.has_changed(), True) + self.assertEqual(self.ring.has_changed(), True) def test_reload(self): os.utime(self.testgz, (time() - 300, time() - 300)) self.ring = ring.Ring(self.testdir, reload_time=0.001, ring_name='whatever') orig_mtime = self.ring._mtime - self.assertEquals(len(self.ring.devs), 5) + self.assertEqual(len(self.ring.devs), 5) self.intended_devs.append( {'id': 3, 'region': 0, 'zone': 3, 'weight': 1.0, 'ip': '10.1.1.1', 'port': 9876}) @@ -219,14 +219,14 @@ class TestRing(TestRingBase): self.intended_devs, self.intended_part_shift).save(self.testgz) sleep(0.1) self.ring.get_nodes('a') - self.assertEquals(len(self.ring.devs), 6) + self.assertEqual(len(self.ring.devs), 6) self.assertNotEquals(self.ring._mtime, orig_mtime) os.utime(self.testgz, (time() - 300, time() - 300)) self.ring = ring.Ring(self.testdir, reload_time=0.001, ring_name='whatever') orig_mtime = self.ring._mtime - self.assertEquals(len(self.ring.devs), 6) + self.assertEqual(len(self.ring.devs), 6) self.intended_devs.append( {'id': 5, 'region': 0, 'zone': 4, 'weight': 1.0, 'ip': '10.5.5.5', 'port': 9876}) @@ -235,7 +235,7 @@ class TestRing(TestRingBase): self.intended_devs, self.intended_part_shift).save(self.testgz) sleep(0.1) self.ring.get_part_nodes(0) - self.assertEquals(len(self.ring.devs), 7) + self.assertEqual(len(self.ring.devs), 7) self.assertNotEquals(self.ring._mtime, orig_mtime) os.utime(self.testgz, (time() - 300, time() - 300)) @@ -243,7 +243,7 @@ class TestRing(TestRingBase): ring_name='whatever') orig_mtime = self.ring._mtime part, nodes = self.ring.get_nodes('a') - self.assertEquals(len(self.ring.devs), 7) + self.assertEqual(len(self.ring.devs), 7) self.intended_devs.append( {'id': 6, 'region': 0, 'zone': 5, 'weight': 1.0, 'ip': '10.6.6.6', 'port': 6000}) @@ -252,14 +252,14 @@ class TestRing(TestRingBase): self.intended_devs, self.intended_part_shift).save(self.testgz) sleep(0.1) next(self.ring.get_more_nodes(part)) - self.assertEquals(len(self.ring.devs), 8) + self.assertEqual(len(self.ring.devs), 8) self.assertNotEquals(self.ring._mtime, orig_mtime) os.utime(self.testgz, (time() - 300, time() - 300)) self.ring = ring.Ring(self.testdir, reload_time=0.001, ring_name='whatever') orig_mtime = self.ring._mtime - self.assertEquals(len(self.ring.devs), 8) + self.assertEqual(len(self.ring.devs), 8) self.intended_devs.append( {'id': 5, 'region': 0, 'zone': 4, 'weight': 1.0, 'ip': '10.5.5.5', 'port': 6000}) @@ -267,7 +267,7 @@ class TestRing(TestRingBase): self.intended_replica2part2dev_id, self.intended_devs, self.intended_part_shift).save(self.testgz) sleep(0.1) - self.assertEquals(len(self.ring.devs), 9) + self.assertEqual(len(self.ring.devs), 9) self.assertNotEquals(self.ring._mtime, orig_mtime) def test_reload_without_replication(self): @@ -309,7 +309,7 @@ class TestRing(TestRingBase): self.testdir, reload_time=self.intended_reload_time, ring_name='without_replication') - self.assertEquals(self.ring.devs, intended_devs) + self.assertEqual(self.ring.devs, intended_devs) def test_reload_old_style_pickled_ring(self): devs = [{'id': 0, 'zone': 0, @@ -361,93 +361,93 @@ class TestRing(TestRingBase): self.testdir, reload_time=self.intended_reload_time, ring_name='without_replication_or_region') - self.assertEquals(self.ring.devs, intended_devs) + self.assertEqual(self.ring.devs, intended_devs) def test_get_part(self): part1 = self.ring.get_part('a') nodes1 = self.ring.get_part_nodes(part1) part2, nodes2 = self.ring.get_nodes('a') - self.assertEquals(part1, part2) - self.assertEquals(nodes1, nodes2) + self.assertEqual(part1, part2) + self.assertEqual(nodes1, nodes2) def test_get_part_nodes(self): part, nodes = self.ring.get_nodes('a') - self.assertEquals(nodes, self.ring.get_part_nodes(part)) + self.assertEqual(nodes, self.ring.get_part_nodes(part)) def test_get_nodes(self): # Yes, these tests are deliberately very fragile. We want to make sure # that if someones changes the results the ring produces, they know it. self.assertRaises(TypeError, self.ring.get_nodes) part, nodes = self.ring.get_nodes('a') - self.assertEquals(part, 0) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 0) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a1') - self.assertEquals(part, 0) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 0) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a4') - self.assertEquals(part, 1) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[1], - self.intended_devs[4]])]) + self.assertEqual(part, 1) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[1], + self.intended_devs[4]])]) part, nodes = self.ring.get_nodes('aa') - self.assertEquals(part, 1) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[1], - self.intended_devs[4]])]) + self.assertEqual(part, 1) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[1], + self.intended_devs[4]])]) part, nodes = self.ring.get_nodes('a', 'c1') - self.assertEquals(part, 0) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 0) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a', 'c0') - self.assertEquals(part, 3) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[1], - self.intended_devs[4]])]) + self.assertEqual(part, 3) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[1], + self.intended_devs[4]])]) part, nodes = self.ring.get_nodes('a', 'c3') - self.assertEquals(part, 2) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 2) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a', 'c2') - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a', 'c', 'o1') - self.assertEquals(part, 1) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[1], - self.intended_devs[4]])]) + self.assertEqual(part, 1) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[1], + self.intended_devs[4]])]) part, nodes = self.ring.get_nodes('a', 'c', 'o5') - self.assertEquals(part, 0) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 0) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a', 'c', 'o0') - self.assertEquals(part, 0) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 0) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) part, nodes = self.ring.get_nodes('a', 'c', 'o2') - self.assertEquals(part, 2) - self.assertEquals(nodes, [dict(node, index=i) for i, node in - enumerate([self.intended_devs[0], - self.intended_devs[3]])]) + self.assertEqual(part, 2) + self.assertEqual(nodes, [dict(node, index=i) for i, node in + enumerate([self.intended_devs[0], + self.intended_devs[3]])]) def add_dev_to_ring(self, new_dev): self.ring.devs.append(new_dev) @@ -506,23 +506,23 @@ class TestRing(TestRingBase): r = ring.Ring(self.testdir, ring_name='whatever') part, devs = r.get_nodes('a', 'c', 'o') primary_zones = set([d['zone'] for d in devs]) - self.assertEquals(part, exp_part) - self.assertEquals([d['id'] for d in devs], exp_devs) - self.assertEquals(primary_zones, exp_zones) + self.assertEqual(part, exp_part) + self.assertEqual([d['id'] for d in devs], exp_devs) + self.assertEqual(primary_zones, exp_zones) devs = list(r.get_more_nodes(part)) - self.assertEquals([d['id'] for d in devs], exp_handoffs) + self.assertEqual([d['id'] for d in devs], exp_handoffs) # The first 6 replicas plus the 3 primary nodes should cover all 9 # zones in this test seen_zones = set(primary_zones) seen_zones.update([d['zone'] for d in devs[:6]]) - self.assertEquals(seen_zones, set(range(1, 10))) + self.assertEqual(seen_zones, set(range(1, 10))) # The first handoff nodes for each partition in the ring devs = [] for part in range(r.partition_count): devs.append(next(r.get_more_nodes(part))['id']) - self.assertEquals(devs, exp_first_handoffs) + self.assertEqual(devs, exp_first_handoffs) # Add a new device we can handoff to. zone = 5 @@ -538,14 +538,14 @@ class TestRing(TestRingBase): # changed at all. part, devs = r.get_nodes('a', 'c', 'o') primary_zones = set([d['zone'] for d in devs]) - self.assertEquals(part, exp_part) - self.assertEquals([d['id'] for d in devs], exp_devs) - self.assertEquals(primary_zones, exp_zones) + self.assertEqual(part, exp_part) + self.assertEqual([d['id'] for d in devs], exp_devs) + self.assertEqual(primary_zones, exp_zones) devs = list(r.get_more_nodes(part)) dev_ids = [d['id'] for d in devs] - self.assertEquals(len(dev_ids), len(exp_handoffs)) + self.assertEqual(len(dev_ids), len(exp_handoffs)) for index, dev in enumerate(dev_ids): - self.assertEquals( + self.assertEqual( dev, exp_handoffs[index], 'handoff differs at position %d\n%s\n%s' % ( index, dev_ids[index:], exp_handoffs[index:])) @@ -553,13 +553,13 @@ class TestRing(TestRingBase): # The handoffs still cover all the non-primary zones first seen_zones = set(primary_zones) seen_zones.update([d['zone'] for d in devs[:6]]) - self.assertEquals(seen_zones, set(range(1, 10))) + self.assertEqual(seen_zones, set(range(1, 10))) devs = [] for part in range(r.partition_count): devs.append(next(r.get_more_nodes(part))['id']) for part in range(r.partition_count): - self.assertEquals( + self.assertEqual( devs[part], exp_first_handoffs[part], 'handoff for partitition %d is now device id %d' % ( part, devs[part])) @@ -588,27 +588,27 @@ class TestRing(TestRingBase): # Test part, devs = r.get_nodes('a', 'c', 'o') primary_zones = set([d['zone'] for d in devs]) - self.assertEquals(part, exp_part) - self.assertEquals([d['id'] for d in devs], exp_devs) - self.assertEquals(primary_zones, exp_zones) + self.assertEqual(part, exp_part) + self.assertEqual([d['id'] for d in devs], exp_devs) + self.assertEqual(primary_zones, exp_zones) devs = list(r.get_more_nodes(part)) dev_ids = [d['id'] for d in devs] - self.assertEquals(len(dev_ids), len(exp_handoffs)) + self.assertEqual(len(dev_ids), len(exp_handoffs)) for index, dev in enumerate(dev_ids): - self.assertEquals( + self.assertEqual( dev, exp_handoffs[index], 'handoff differs at position %d\n%s\n%s' % ( index, dev_ids[index:], exp_handoffs[index:])) seen_zones = set(primary_zones) seen_zones.update([d['zone'] for d in devs[:6]]) - self.assertEquals(seen_zones, set(range(1, 10))) + self.assertEqual(seen_zones, set(range(1, 10))) devs = [] for part in range(r.partition_count): devs.append(next(r.get_more_nodes(part))['id']) for part in range(r.partition_count): - self.assertEquals( + self.assertEqual( devs[part], exp_first_handoffs[part], 'handoff for partitition %d is now device id %d' % ( part, devs[part])) @@ -668,28 +668,28 @@ class TestRing(TestRingBase): # Test part, devs = r.get_nodes('a', 'c', 'o') primary_zones = set([d['zone'] for d in devs]) - self.assertEquals(part, exp_part) - self.assertEquals([d['id'] for d in devs], exp_devs) - self.assertEquals(primary_zones, exp_zones) + self.assertEqual(part, exp_part) + self.assertEqual([d['id'] for d in devs], exp_devs) + self.assertEqual(primary_zones, exp_zones) devs = list(r.get_more_nodes(part)) dev_ids = [d['id'] for d in devs] - self.assertEquals(len(dev_ids), len(exp_handoffs)) + self.assertEqual(len(dev_ids), len(exp_handoffs)) for index, dev in enumerate(dev_ids): - self.assertEquals( + self.assertEqual( dev, exp_handoffs[index], 'handoff differs at position %d\n%s\n%s' % ( index, dev_ids[index:], exp_handoffs[index:])) seen_zones = set(primary_zones) seen_zones.update([d['zone'] for d in devs[:6]]) - self.assertEquals(seen_zones, set(range(1, 10))) + self.assertEqual(seen_zones, set(range(1, 10))) devs = [] for part in range(r.partition_count): devs.append(next(r.get_more_nodes(part))['id']) for part in range(r.partition_count): - self.assertEquals( + self.assertEqual( devs[part], exp_first_handoffs[part], 'handoff for partitition %d is now device id %d' % ( part, devs[part])) @@ -710,22 +710,22 @@ class TestRing(TestRingBase): part2, devs2 = r.get_nodes('a', 'c', 'o2') primary_zones2 = set([d['zone'] for d in devs2]) - self.assertEquals(part2, exp_part2) - self.assertEquals([d['id'] for d in devs2], exp_devs2) - self.assertEquals(primary_zones2, exp_zones2) + self.assertEqual(part2, exp_part2) + self.assertEqual([d['id'] for d in devs2], exp_devs2) + self.assertEqual(primary_zones2, exp_zones2) devs2 = list(r.get_more_nodes(part2)) dev_ids2 = [d['id'] for d in devs2] - self.assertEquals(len(dev_ids2), len(exp_handoffs2)) + self.assertEqual(len(dev_ids2), len(exp_handoffs2)) for index, dev in enumerate(dev_ids2): - self.assertEquals( + self.assertEqual( dev, exp_handoffs2[index], 'handoff differs at position %d\n%s\n%s' % ( index, dev_ids2[index:], exp_handoffs2[index:])) seen_zones = set(primary_zones2) seen_zones.update([d['zone'] for d in devs2[:6]]) - self.assertEquals(seen_zones, set(range(1, 10))) + self.assertEqual(seen_zones, set(range(1, 10))) # Test distribution across regions rb.set_replicas(3) @@ -753,14 +753,14 @@ class TestRing(TestRingBase): seen_regions = set(primary_regions) seen_regions.update([d['region'] for d in more_devs[:2]]) - self.assertEquals(seen_regions, set(range(0, 5))) + self.assertEqual(seen_regions, set(range(0, 5))) # There are 13 zones now, so the first 13 nodes should all have # distinct zones (that's r0z0, r0z1, ..., r0z8, r1z1, r2z1, r3z1, and # r4z1). seen_zones = set(primary_zones) seen_zones.update([(d['region'], d['zone']) for d in more_devs[:10]]) - self.assertEquals(13, len(seen_zones)) + self.assertEqual(13, len(seen_zones)) # Here's a brittle canary-in-the-coalmine test to make sure the region # handoff computation didn't change accidentally @@ -774,9 +774,9 @@ class TestRing(TestRingBase): 51, 70, 82, 67, 68, 8, 95, 91, 55, 59, 85] dev_ids = [d['id'] for d in more_devs] - self.assertEquals(len(dev_ids), len(exp_handoffs)) + self.assertEqual(len(dev_ids), len(exp_handoffs)) for index, dev_id in enumerate(dev_ids): - self.assertEquals( + self.assertEqual( dev_id, exp_handoffs[index], 'handoff differs at position %d\n%s\n%s' % ( index, dev_ids[index:], exp_handoffs[index:])) diff --git a/test/unit/common/ring/test_utils.py b/test/unit/common/ring/test_utils.py index 603618420e..3cba0fb512 100644 --- a/test/unit/common/ring/test_utils.py +++ b/test/unit/common/ring/test_utils.py @@ -307,7 +307,7 @@ class TestUtils(unittest.TestCase): } new_cmd_format, opts, args = validate_args(argv) search_values = parse_search_values_from_opts(opts) - self.assertEquals(search_values, expected) + self.assertEqual(search_values, expected) argv = \ ["--id", "1", "--region", "2", "--zone", "3", @@ -338,7 +338,7 @@ class TestUtils(unittest.TestCase): } new_cmd_format, opts, args = validate_args(argv) search_values = parse_search_values_from_opts(opts) - self.assertEquals(search_values, expected) + self.assertEqual(search_values, expected) argv = \ ["--id", "1", "--region", "2", "--zone", "3", @@ -357,7 +357,7 @@ class TestUtils(unittest.TestCase): "--change-meta", "some meta data for change"] new_cmd_format, opts, args = validate_args(argv) search_values = parse_search_values_from_opts(opts) - self.assertEquals(search_values, expected) + self.assertEqual(search_values, expected) def test_parse_change_values_from_opts(self): argv = \ @@ -385,7 +385,7 @@ class TestUtils(unittest.TestCase): } new_cmd_format, opts, args = validate_args(argv) search_values = parse_change_values_from_opts(opts) - self.assertEquals(search_values, expected) + self.assertEqual(search_values, expected) argv = \ ["--id", "1", "--region", "2", "--zone", "3", @@ -412,7 +412,7 @@ class TestUtils(unittest.TestCase): } new_cmd_format, opts, args = validate_args(argv) search_values = parse_change_values_from_opts(opts) - self.assertEquals(search_values, expected) + self.assertEqual(search_values, expected) argv = \ ["--id", "1", "--region", "2", "--zone", "3", @@ -431,7 +431,7 @@ class TestUtils(unittest.TestCase): "--change-meta", "some meta data for change"] new_cmd_format, opts, args = validate_args(argv) search_values = parse_change_values_from_opts(opts) - self.assertEquals(search_values, expected) + self.assertEqual(search_values, expected) def test_validate_args(self): argv = \ @@ -560,20 +560,20 @@ class TestUtils(unittest.TestCase): def test_parse_builder_ring_filename_args(self): args = 'swift-ring-builder object.builder write_ring' - self.assertEquals(( + self.assertEqual(( 'object.builder', 'object.ring.gz' ), parse_builder_ring_filename_args(args.split())) args = 'swift-ring-builder container.ring.gz write_builder' - self.assertEquals(( + self.assertEqual(( 'container.builder', 'container.ring.gz' ), parse_builder_ring_filename_args(args.split())) # builder name arg should always fall through args = 'swift-ring-builder test create' - self.assertEquals(( + self.assertEqual(( 'test', 'test.ring.gz' ), parse_builder_ring_filename_args(args.split())) args = 'swift-ring-builder my.file.name create' - self.assertEquals(( + self.assertEqual(( 'my.file.name', 'my.file.name.ring.gz' ), parse_builder_ring_filename_args(args.split())) @@ -600,7 +600,7 @@ class TestUtils(unittest.TestCase): } opts, args = parse_args(argv) device = build_dev_from_opts(opts) - self.assertEquals(device, expected) + self.assertEqual(device, expected) argv = \ ["--region", "2", "--zone", "3", @@ -640,7 +640,7 @@ class TestUtils(unittest.TestCase): 'weight': 100.0, 'zone': 1, } - self.assertEquals(device, expected) + self.assertEqual(device, expected) args = '-r 1 -z 1 -i test.com -p 6010 -d d1 -w 100'.split() opts, _ = parse_args(args) @@ -656,7 +656,7 @@ class TestUtils(unittest.TestCase): 'weight': 100.0, 'zone': 1, } - self.assertEquals(device, expected) + self.assertEqual(device, expected) def test_dispersion_report(self): rb = ring.RingBuilder(8, 3, 0) diff --git a/test/unit/common/test_base_storage_server.py b/test/unit/common/test_base_storage_server.py index bd23692f05..b8e955f13a 100644 --- a/test/unit/common/test_base_storage_server.py +++ b/test/unit/common/test_base_storage_server.py @@ -60,7 +60,7 @@ class TestBaseStorageServer(unittest.TestCase): try: baseserver.server_type except NotImplementedError as e: - self.assertEquals(str(e), msg) + self.assertEqual(str(e), msg) def test_allowed_methods(self): conf = {'devices': self.testdir, 'mount_check': 'false', @@ -68,34 +68,34 @@ class TestBaseStorageServer(unittest.TestCase): # test what's available in the base class allowed_methods_test = FakeOPTIONS(conf).allowed_methods - self.assertEquals(allowed_methods_test, ['OPTIONS']) + self.assertEqual(allowed_methods_test, ['OPTIONS']) # test that a subclass can add allowed methods allowed_methods_test = FakeANOTHER(conf).allowed_methods allowed_methods_test.sort() - self.assertEquals(allowed_methods_test, ['ANOTHER', 'OPTIONS']) + self.assertEqual(allowed_methods_test, ['ANOTHER', 'OPTIONS']) conf = {'devices': self.testdir, 'mount_check': 'false', 'replication_server': 'true'} # test what's available in the base class allowed_methods_test = FakeOPTIONS(conf).allowed_methods - self.assertEquals(allowed_methods_test, []) + self.assertEqual(allowed_methods_test, []) # test that a subclass can add allowed methods allowed_methods_test = FakeANOTHER(conf).allowed_methods - self.assertEquals(allowed_methods_test, []) + self.assertEqual(allowed_methods_test, []) conf = {'devices': self.testdir, 'mount_check': 'false'} # test what's available in the base class allowed_methods_test = FakeOPTIONS(conf).allowed_methods - self.assertEquals(allowed_methods_test, ['OPTIONS']) + self.assertEqual(allowed_methods_test, ['OPTIONS']) # test that a subclass can add allowed methods allowed_methods_test = FakeANOTHER(conf).allowed_methods allowed_methods_test.sort() - self.assertEquals(allowed_methods_test, ['ANOTHER', 'OPTIONS']) + self.assertEqual(allowed_methods_test, ['ANOTHER', 'OPTIONS']) def test_OPTIONS_error(self): msg = 'Storage nodes have not implemented the Server type.' @@ -109,7 +109,7 @@ class TestBaseStorageServer(unittest.TestCase): try: baseserver.OPTIONS(req) except NotImplementedError as e: - self.assertEquals(str(e), msg) + self.assertEqual(str(e), msg) def test_OPTIONS(self): conf = {'devices': self.testdir, 'mount_check': 'false', @@ -117,6 +117,6 @@ class TestBaseStorageServer(unittest.TestCase): req = Request.blank('/sda1/p/a/c/o', {'REQUEST_METHOD': 'OPTIONS'}) req.content_length = 0 resp = FakeOPTIONS(conf).OPTIONS(req) - self.assertEquals(resp.headers['Allow'], 'OPTIONS') - self.assertEquals(resp.headers['Server'], - 'test-server/' + swift_version) + self.assertEqual(resp.headers['Allow'], 'OPTIONS') + self.assertEqual(resp.headers['Server'], + 'test-server/' + swift_version) diff --git a/test/unit/common/test_bufferedhttp.py b/test/unit/common/test_bufferedhttp.py index 6e51973147..aefb54a1cb 100644 --- a/test/unit/common/test_bufferedhttp.py +++ b/test/unit/common/test_bufferedhttp.py @@ -55,7 +55,7 @@ class TestBufferedHTTP(unittest.TestCase): fp.write('HTTP/1.1 200 OK\r\nContent-Length: 8\r\n\r\n' 'RESPONSE') fp.flush() - self.assertEquals( + self.assertEqual( fp.readline(), 'PUT /dev/%s/path/..%%25/?omg&no=%%7f HTTP/1.1\r\n' % expected_par) @@ -65,9 +65,9 @@ class TestBufferedHTTP(unittest.TestCase): headers[line.split(':')[0].lower()] = \ line.split(':')[1].strip() line = fp.readline() - self.assertEquals(headers['content-length'], '7') - self.assertEquals(headers['x-header'], 'value') - self.assertEquals(fp.readline(), 'REQUEST\r\n') + self.assertEqual(headers['content-length'], '7') + self.assertEqual(headers['x-header'], 'value') + self.assertEqual(fp.readline(), 'REQUEST\r\n') except BaseException as err: return err return None @@ -87,9 +87,9 @@ class TestBufferedHTTP(unittest.TestCase): resp = conn.getresponse() body = resp.read() conn.close() - self.assertEquals(resp.status, 200) - self.assertEquals(resp.reason, 'OK') - self.assertEquals(body, 'RESPONSE') + self.assertEqual(resp.status, 200) + self.assertEqual(resp.reason, 'OK') + self.assertEqual(body, 'RESPONSE') finally: err = event.wait() if err: diff --git a/test/unit/common/test_constraints.py b/test/unit/common/test_constraints.py index 1fd3411ad2..b250907527 100644 --- a/test/unit/common/test_constraints.py +++ b/test/unit/common/test_constraints.py @@ -39,12 +39,12 @@ class TestConstraints(unittest.TestCase): def test_check_metadata_empty(self): headers = {} - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object'), None) def test_check_metadata_good(self): headers = {'X-Object-Meta-Name': 'Value'} - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object'), None) def test_check_metadata_empty_name(self): @@ -55,11 +55,11 @@ class TestConstraints(unittest.TestCase): def test_check_metadata_name_length(self): name = 'a' * constraints.MAX_META_NAME_LENGTH headers = {'X-Object-Meta-%s' % name: 'v'} - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object'), None) name = 'a' * (constraints.MAX_META_NAME_LENGTH + 1) headers = {'X-Object-Meta-%s' % name: 'v'} - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST) self.assertIn( ('X-Object-Meta-%s' % name).lower(), @@ -69,11 +69,11 @@ class TestConstraints(unittest.TestCase): def test_check_metadata_value_length(self): value = 'a' * constraints.MAX_META_VALUE_LENGTH headers = {'X-Object-Meta-Name': value} - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object'), None) value = 'a' * (constraints.MAX_META_VALUE_LENGTH + 1) headers = {'X-Object-Meta-Name': value} - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST) self.assertIn( 'x-object-meta-name', @@ -90,10 +90,10 @@ class TestConstraints(unittest.TestCase): headers = {} for x in range(constraints.MAX_META_COUNT): headers['X-Object-Meta-%d' % x] = 'v' - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object'), None) headers['X-Object-Meta-Too-Many'] = 'v' - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST) def test_check_metadata_size(self): @@ -108,7 +108,7 @@ class TestConstraints(unittest.TestCase): 'v' * constraints.MAX_META_VALUE_LENGTH size += chunk x += 1 - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object'), None) # add two more headers in case adding just one falls exactly on the # limit (eg one header adds 1024 and the limit is 2048) @@ -118,46 +118,46 @@ class TestConstraints(unittest.TestCase): headers['X-Object-Meta-%04d%s' % (x + 1, 'a' * (constraints.MAX_META_NAME_LENGTH - 4))] = \ 'v' * constraints.MAX_META_VALUE_LENGTH - self.assertEquals(constraints.check_metadata(Request.blank( + self.assertEqual(constraints.check_metadata(Request.blank( '/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST) def test_check_object_creation_content_length(self): headers = {'Content-Length': str(constraints.MAX_FILE_SIZE), 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name'), None) headers = {'Content-Length': str(constraints.MAX_FILE_SIZE + 1), 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation( + self.assertEqual(constraints.check_object_creation( Request.blank('/', headers=headers), 'object_name').status_int, HTTP_REQUEST_ENTITY_TOO_LARGE) headers = {'Transfer-Encoding': 'chunked', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name'), None) headers = {'Transfer-Encoding': 'gzip', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name').status_int, HTTP_BAD_REQUEST) headers = {'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation( + self.assertEqual(constraints.check_object_creation( Request.blank('/', headers=headers), 'object_name').status_int, HTTP_LENGTH_REQUIRED) headers = {'Content-Length': 'abc', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name').status_int, HTTP_BAD_REQUEST) headers = {'Transfer-Encoding': 'gzip,chunked', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name').status_int, HTTP_NOT_IMPLEMENTED) @@ -165,26 +165,26 @@ class TestConstraints(unittest.TestCase): headers = {'Content-Length': '0', 'X-Copy-From': 'c/o2', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name'), None) headers = {'Content-Length': '1', 'X-Copy-From': 'c/o2', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name').status_int, HTTP_BAD_REQUEST) headers = {'Transfer-Encoding': 'chunked', 'X-Copy-From': 'c/o2', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name'), None) # a content-length header is always required headers = {'X-Copy-From': 'c/o2', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name').status_int, HTTP_LENGTH_REQUIRED) @@ -192,20 +192,20 @@ class TestConstraints(unittest.TestCase): headers = {'Transfer-Encoding': 'chunked', 'Content-Type': 'text/plain'} name = 'o' * constraints.MAX_OBJECT_NAME_LENGTH - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), name), None) name = 'o' * (constraints.MAX_OBJECT_NAME_LENGTH + 1) - self.assertEquals(constraints.check_object_creation( + self.assertEqual(constraints.check_object_creation( Request.blank('/', headers=headers), name).status_int, HTTP_BAD_REQUEST) def test_check_object_creation_content_type(self): headers = {'Transfer-Encoding': 'chunked', 'Content-Type': 'text/plain'} - self.assertEquals(constraints.check_object_creation(Request.blank( + self.assertEqual(constraints.check_object_creation(Request.blank( '/', headers=headers), 'object_name'), None) headers = {'Transfer-Encoding': 'chunked'} - self.assertEquals(constraints.check_object_creation( + self.assertEqual(constraints.check_object_creation( Request.blank('/', headers=headers), 'object_name').status_int, HTTP_BAD_REQUEST) @@ -214,7 +214,7 @@ class TestConstraints(unittest.TestCase): 'Content-Type': '\xff\xff'} resp = constraints.check_object_creation( Request.blank('/', headers=headers), 'object_name') - self.assertEquals(resp.status_int, HTTP_BAD_REQUEST) + self.assertEqual(resp.status_int, HTTP_BAD_REQUEST) self.assertTrue('Content-Type' in resp.body) def test_check_object_creation_bad_delete_headers(self): @@ -223,7 +223,7 @@ class TestConstraints(unittest.TestCase): 'X-Delete-After': 'abc'} resp = constraints.check_object_creation( Request.blank('/', headers=headers), 'object_name') - self.assertEquals(resp.status_int, HTTP_BAD_REQUEST) + self.assertEqual(resp.status_int, HTTP_BAD_REQUEST) self.assertTrue('Non-integer X-Delete-After' in resp.body) t = str(int(time.time() - 60)) @@ -232,7 +232,7 @@ class TestConstraints(unittest.TestCase): 'X-Delete-At': t} resp = constraints.check_object_creation( Request.blank('/', headers=headers), 'object_name') - self.assertEquals(resp.status_int, HTTP_BAD_REQUEST) + self.assertEqual(resp.status_int, HTTP_BAD_REQUEST) self.assertTrue('X-Delete-At in past' in resp.body) def test_check_delete_headers(self): @@ -249,7 +249,7 @@ class TestConstraints(unittest.TestCase): resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('Non-integer X-Delete-After' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -259,7 +259,7 @@ class TestConstraints(unittest.TestCase): resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('Non-integer X-Delete-After' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -269,7 +269,7 @@ class TestConstraints(unittest.TestCase): resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('X-Delete-After in past' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -281,14 +281,14 @@ class TestConstraints(unittest.TestCase): Request.blank('/', headers=headers)) self.assertTrue(isinstance(resp, Request)) self.assertTrue('x-delete-at' in resp.headers) - self.assertEquals(resp.headers.get('X-Delete-At'), t) + self.assertEqual(resp.headers.get('X-Delete-At'), t) headers = {'X-Delete-At': 'abc'} try: resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('Non-integer X-Delete-At' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -299,7 +299,7 @@ class TestConstraints(unittest.TestCase): resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('Non-integer X-Delete-At' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -310,7 +310,7 @@ class TestConstraints(unittest.TestCase): resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('X-Delete-At in past' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -321,7 +321,7 @@ class TestConstraints(unittest.TestCase): resp = constraints.check_delete_headers( Request.blank('/', headers=headers)) except HTTPException as e: - self.assertEquals(e.status_int, HTTP_BAD_REQUEST) + self.assertEqual(e.status_int, HTTP_BAD_REQUEST) self.assertTrue('X-Delete-At in past' in e.body) else: self.fail("Should have failed with HTTPBadRequest") @@ -435,8 +435,8 @@ class TestConstraints(unittest.TestCase): '/v/a/c/o', headers={'x-object-meta-hello': 'ab' * constraints.MAX_HEADER_SIZE}) - self.assertEquals(constraints.check_metadata(req, 'object').status_int, - HTTP_BAD_REQUEST) + self.assertEqual(constraints.check_metadata(req, 'object').status_int, + HTTP_BAD_REQUEST) self.assertIn('x-object-meta-hello', constraints.check_metadata(req, 'object').body.lower()) @@ -544,21 +544,21 @@ class TestConstraintsConfig(unittest.TestCase): # module level attrs (that aren't in OVERRIDE) should have the # same value as the DEFAULT map module_level_value = getattr(constraints, key.upper()) - self.assertEquals(constraints.DEFAULT_CONSTRAINTS[key], - module_level_value) + self.assertEqual(constraints.DEFAULT_CONSTRAINTS[key], + module_level_value) def test_effective_constraints(self): for key in constraints.DEFAULT_CONSTRAINTS: # module level attrs should always mirror the same value as the # EFFECTIVE map module_level_value = getattr(constraints, key.upper()) - self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS[key], - module_level_value) + self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS[key], + module_level_value) # if there are local over-rides in swift.conf those should be # reflected in the EFFECTIVE, otherwise we expect the DEFAULTs - self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS[key], - constraints.OVERRIDE_CONSTRAINTS.get( - key, constraints.DEFAULT_CONSTRAINTS[key])) + self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS[key], + constraints.OVERRIDE_CONSTRAINTS.get( + key, constraints.DEFAULT_CONSTRAINTS[key])) def test_override_constraints(self): try: @@ -573,14 +573,14 @@ class TestConstraintsConfig(unittest.TestCase): for key in constraints.DEFAULT_CONSTRAINTS: # module level attrs should all be 1 module_level_value = getattr(constraints, key.upper()) - self.assertEquals(module_level_value, 1) + self.assertEqual(module_level_value, 1) # all keys should be in OVERRIDE - self.assertEquals(constraints.OVERRIDE_CONSTRAINTS[key], - module_level_value) + self.assertEqual(constraints.OVERRIDE_CONSTRAINTS[key], + module_level_value) # module level attrs should always mirror the same value as # the EFFECTIVE map - self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS[key], - module_level_value) + self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS[key], + module_level_value) finally: constraints.reload_constraints() @@ -595,18 +595,18 @@ class TestConstraintsConfig(unittest.TestCase): with mock.patch.object(utils, 'SWIFT_CONF_FILE', f.name): constraints.reload_constraints() self.assertTrue(constraints.SWIFT_CONSTRAINTS_LOADED) - self.assertEquals(sorted(constraints.DEFAULT_CONSTRAINTS.keys()), - sorted(constraints.OVERRIDE_CONSTRAINTS.keys())) + self.assertEqual(sorted(constraints.DEFAULT_CONSTRAINTS.keys()), + sorted(constraints.OVERRIDE_CONSTRAINTS.keys())) # file is now deleted... with mock.patch.object(utils, 'SWIFT_CONF_FILE', f.name): constraints.reload_constraints() # no constraints have been loaded from non-existent swift.conf self.assertFalse(constraints.SWIFT_CONSTRAINTS_LOADED) # no constraints are in OVERRIDE - self.assertEquals([], constraints.OVERRIDE_CONSTRAINTS.keys()) + self.assertEqual([], constraints.OVERRIDE_CONSTRAINTS.keys()) # the EFFECTIVE constraints mirror DEFAULT - self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS, - constraints.DEFAULT_CONSTRAINTS) + self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS, + constraints.DEFAULT_CONSTRAINTS) finally: constraints.reload_constraints() diff --git a/test/unit/common/test_daemon.py b/test/unit/common/test_daemon.py index cab9d4f2de..b81e231571 100644 --- a/test/unit/common/test_daemon.py +++ b/test/unit/common/test_daemon.py @@ -51,7 +51,7 @@ class TestDaemon(unittest.TestCase): def test_create(self): d = daemon.Daemon({}) - self.assertEquals(d.conf, {}) + self.assertEqual(d.conf, {}) self.assertTrue(isinstance(d.logger, utils.LogAdapter)) def test_stubs(self): @@ -77,20 +77,20 @@ class TestRunDaemon(unittest.TestCase): self.assertFalse(MyDaemon.once_called) # test default d.run() - self.assertEquals(d.forever_called, True) + self.assertEqual(d.forever_called, True) # test once d.run(once=True) - self.assertEquals(d.once_called, True) + self.assertEqual(d.once_called, True) def test_run_daemon(self): sample_conf = "[my-daemon]\nuser = %s\n" % getuser() with tmpfile(sample_conf) as conf_file: with patch.dict('os.environ', {'TZ': ''}): daemon.run_daemon(MyDaemon, conf_file) - self.assertEquals(MyDaemon.forever_called, True) + self.assertEqual(MyDaemon.forever_called, True) self.assertTrue(os.environ['TZ'] is not '') daemon.run_daemon(MyDaemon, conf_file, once=True) - self.assertEquals(MyDaemon.once_called, True) + self.assertEqual(MyDaemon.once_called, True) # test raise in daemon code MyDaemon.run_once = MyDaemon.run_raise diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index cc65d40800..4bb37ffba9 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -70,16 +70,16 @@ class TestDictFactory(unittest.TestCase): conn.execute('INSERT INTO test (one, two) VALUES ("def", 456)') conn.commit() curs = conn.execute('SELECT one, two FROM test') - self.assertEquals(dict_factory(curs, next(curs)), - {'one': 'abc', 'two': 123}) - self.assertEquals(dict_factory(curs, next(curs)), - {'one': 'def', 'two': 456}) + self.assertEqual(dict_factory(curs, next(curs)), + {'one': 'abc', 'two': 123}) + self.assertEqual(dict_factory(curs, next(curs)), + {'one': 'def', 'two': 456}) class TestChexor(unittest.TestCase): def test_normal_case(self): - self.assertEquals( + self.assertEqual( chexor('d41d8cd98f00b204e9800998ecf8427e', 'new name', normalize_timestamp(1)), '4f2ea31ac14d4273fe32ba08062b21de') @@ -459,13 +459,13 @@ class TestExampleBroker(unittest.TestCase): def test_get_max_row(self): broker = self.broker_class(':memory:', account='a', container='c') broker.initialize(next(self.ts), storage_policy_index=int(self.policy)) - self.assertEquals(-1, broker.get_max_row()) + self.assertEqual(-1, broker.get_max_row()) self.put_item(broker, next(self.ts)) - self.assertEquals(1, broker.get_max_row()) + self.assertEqual(1, broker.get_max_row()) self.delete_item(broker, next(self.ts)) - self.assertEquals(2, broker.get_max_row()) + self.assertEqual(2, broker.get_max_row()) self.put_item(broker, next(self.ts)) - self.assertEquals(3, broker.get_max_row()) + self.assertEqual(3, broker.get_max_row()) def test_get_info(self): broker = self.broker_class(':memory:', account='test', container='c') @@ -531,10 +531,10 @@ class TestExampleBroker(unittest.TestCase): with patch('swift.common.db.time.time', new=lambda: created_at): broker.initialize(put_timestamp, storage_policy_index=int(self.policy)) - self.assertEquals(broker.get_info()['status_changed_at'], - put_timestamp) - self.assertEquals(broker.get_info()['created_at'], - Timestamp(created_at).internal) + self.assertEqual(broker.get_info()['status_changed_at'], + put_timestamp) + self.assertEqual(broker.get_info()['created_at'], + Timestamp(created_at).internal) status_changed_at = next(self.ts) broker.update_status_changed_at(status_changed_at) self.assertEqual(broker.get_info()['status_changed_at'], @@ -624,7 +624,7 @@ class TestDatabaseBroker(unittest.TestCase): b = DatabaseBroker(db_file) b._preallocate() # We only wrote 1 byte, so we should end with the 1st step or 1 MB. - self.assertEquals(test_size[0], 1024 * 1024) + self.assertEqual(test_size[0], 1024 * 1024) def test_initialize(self): self.assertRaises(AttributeError, @@ -642,7 +642,7 @@ class TestDatabaseBroker(unittest.TestCase): broker._initialize = stub broker.initialize(normalize_timestamp('1')) self.assertTrue(hasattr(stub_dict['args'][0], 'execute')) - self.assertEquals(stub_dict['args'][1], '0000000001.00000') + self.assertEqual(stub_dict['args'][1], '0000000001.00000') with broker.get() as conn: conn.execute('SELECT * FROM outgoing_sync') conn.execute('SELECT * FROM incoming_sync') @@ -650,7 +650,7 @@ class TestDatabaseBroker(unittest.TestCase): broker._initialize = stub broker.initialize(normalize_timestamp('1')) self.assertTrue(hasattr(stub_dict['args'][0], 'execute')) - self.assertEquals(stub_dict['args'][1], '0000000001.00000') + self.assertEqual(stub_dict['args'][1], '0000000001.00000') with broker.get() as conn: conn.execute('SELECT * FROM outgoing_sync') conn.execute('SELECT * FROM incoming_sync') @@ -727,14 +727,14 @@ class TestDatabaseBroker(unittest.TestCase): pass broker = DatabaseBroker(os.path.join(self.testdir, '1.db')) with broker.get() as conn: - self.assertEquals( + self.assertEqual( [r[0] for r in conn.execute('SELECT * FROM test')], []) with broker.get() as conn: conn.execute('INSERT INTO test (one) VALUES ("1")') conn.commit() broker = DatabaseBroker(os.path.join(self.testdir, '1.db')) with broker.get() as conn: - self.assertEquals( + self.assertEqual( [r[0] for r in conn.execute('SELECT * FROM test')], ['1']) dbpath = os.path.join(self.testdir, 'dev', 'dbs', 'par', 'pre', 'db') @@ -754,7 +754,7 @@ class TestDatabaseBroker(unittest.TestCase): conn.execute('SELECT * FROM test') except Exception as err: exc = err - self.assertEquals( + self.assertEqual( str(exc), 'Quarantined %s to %s due to malformed database' % (dbpath, qpath)) @@ -770,7 +770,7 @@ class TestDatabaseBroker(unittest.TestCase): conn.execute('SELECT * FROM test') except Exception as err: exc = err - self.assertEquals( + self.assertEqual( str(exc), 'Quarantined %s to %s due to corrupted database' % (dbpath, qpath)) @@ -829,39 +829,39 @@ class TestDatabaseBroker(unittest.TestCase): broker.newid(uuid2) with broker.get() as conn: uuids = [r[0] for r in conn.execute('SELECT * FROM test_stat')] - self.assertEquals(len(uuids), 1) + self.assertEqual(len(uuids), 1) self.assertNotEquals(uuids[0], uuid1) uuid1 = uuids[0] points = [(r[0], r[1]) for r in conn.execute( 'SELECT sync_point, ' 'remote_id FROM incoming_sync WHERE remote_id = ?', (uuid2,))] - self.assertEquals(len(points), 1) - self.assertEquals(points[0][0], -1) - self.assertEquals(points[0][1], uuid2) + self.assertEqual(len(points), 1) + self.assertEqual(points[0][0], -1) + self.assertEqual(points[0][1], uuid2) conn.execute('INSERT INTO test (one) VALUES ("1")') conn.commit() uuid3 = str(uuid4()) broker.newid(uuid3) with broker.get() as conn: uuids = [r[0] for r in conn.execute('SELECT * FROM test_stat')] - self.assertEquals(len(uuids), 1) + self.assertEqual(len(uuids), 1) self.assertNotEquals(uuids[0], uuid1) uuid1 = uuids[0] points = [(r[0], r[1]) for r in conn.execute( 'SELECT sync_point, ' 'remote_id FROM incoming_sync WHERE remote_id = ?', (uuid3,))] - self.assertEquals(len(points), 1) - self.assertEquals(points[0][1], uuid3) + self.assertEqual(len(points), 1) + self.assertEqual(points[0][1], uuid3) broker.newid(uuid2) with broker.get() as conn: uuids = [r[0] for r in conn.execute('SELECT * FROM test_stat')] - self.assertEquals(len(uuids), 1) + self.assertEqual(len(uuids), 1) self.assertNotEquals(uuids[0], uuid1) points = [(r[0], r[1]) for r in conn.execute( 'SELECT sync_point, ' 'remote_id FROM incoming_sync WHERE remote_id = ?', (uuid2,))] - self.assertEquals(len(points), 1) - self.assertEquals(points[0][1], uuid2) + self.assertEqual(len(points), 1) + self.assertEqual(points[0][1], uuid2) def test_get_items_since(self): broker = DatabaseBroker(':memory:') @@ -876,14 +876,14 @@ class TestDatabaseBroker(unittest.TestCase): conn.commit() broker._initialize = _initialize broker.initialize(normalize_timestamp('1')) - self.assertEquals(broker.get_items_since(-1, 10), - [{'one': '1'}, {'one': '2'}, {'one': '3'}]) - self.assertEquals(broker.get_items_since(-1, 2), - [{'one': '1'}, {'one': '2'}]) - self.assertEquals(broker.get_items_since(1, 2), - [{'one': '2'}, {'one': '3'}]) - self.assertEquals(broker.get_items_since(3, 2), []) - self.assertEquals(broker.get_items_since(999, 2), []) + self.assertEqual(broker.get_items_since(-1, 10), + [{'one': '1'}, {'one': '2'}, {'one': '3'}]) + self.assertEqual(broker.get_items_since(-1, 2), + [{'one': '1'}, {'one': '2'}]) + self.assertEqual(broker.get_items_since(1, 2), + [{'one': '2'}, {'one': '3'}]) + self.assertEqual(broker.get_items_since(3, 2), []) + self.assertEqual(broker.get_items_since(999, 2), []) def test_get_sync(self): broker = DatabaseBroker(':memory:') @@ -901,29 +901,29 @@ class TestDatabaseBroker(unittest.TestCase): broker._initialize = _initialize broker.initialize(normalize_timestamp('1')) uuid2 = str(uuid4()) - self.assertEquals(broker.get_sync(uuid2), -1) + self.assertEqual(broker.get_sync(uuid2), -1) broker.newid(uuid2) - self.assertEquals(broker.get_sync(uuid2), 1) + self.assertEqual(broker.get_sync(uuid2), 1) uuid3 = str(uuid4()) - self.assertEquals(broker.get_sync(uuid3), -1) + self.assertEqual(broker.get_sync(uuid3), -1) with broker.get() as conn: conn.execute('INSERT INTO test (one) VALUES ("2")') conn.commit() broker.newid(uuid3) - self.assertEquals(broker.get_sync(uuid2), 1) - self.assertEquals(broker.get_sync(uuid3), 2) - self.assertEquals(broker.get_sync(uuid2, incoming=False), -1) - self.assertEquals(broker.get_sync(uuid3, incoming=False), -1) + self.assertEqual(broker.get_sync(uuid2), 1) + self.assertEqual(broker.get_sync(uuid3), 2) + self.assertEqual(broker.get_sync(uuid2, incoming=False), -1) + self.assertEqual(broker.get_sync(uuid3, incoming=False), -1) broker.merge_syncs([{'sync_point': 1, 'remote_id': uuid2}], incoming=False) - self.assertEquals(broker.get_sync(uuid2), 1) - self.assertEquals(broker.get_sync(uuid3), 2) - self.assertEquals(broker.get_sync(uuid2, incoming=False), 1) - self.assertEquals(broker.get_sync(uuid3, incoming=False), -1) + self.assertEqual(broker.get_sync(uuid2), 1) + self.assertEqual(broker.get_sync(uuid3), 2) + self.assertEqual(broker.get_sync(uuid2, incoming=False), 1) + self.assertEqual(broker.get_sync(uuid3, incoming=False), -1) broker.merge_syncs([{'sync_point': 2, 'remote_id': uuid3}], incoming=False) - self.assertEquals(broker.get_sync(uuid2, incoming=False), 1) - self.assertEquals(broker.get_sync(uuid3, incoming=False), 2) + self.assertEqual(broker.get_sync(uuid2, incoming=False), 1) + self.assertEqual(broker.get_sync(uuid3, incoming=False), 2) def test_merge_syncs(self): broker = DatabaseBroker(':memory:') @@ -934,22 +934,22 @@ class TestDatabaseBroker(unittest.TestCase): broker.initialize(normalize_timestamp('1')) uuid2 = str(uuid4()) broker.merge_syncs([{'sync_point': 1, 'remote_id': uuid2}]) - self.assertEquals(broker.get_sync(uuid2), 1) + self.assertEqual(broker.get_sync(uuid2), 1) uuid3 = str(uuid4()) broker.merge_syncs([{'sync_point': 2, 'remote_id': uuid3}]) - self.assertEquals(broker.get_sync(uuid2), 1) - self.assertEquals(broker.get_sync(uuid3), 2) - self.assertEquals(broker.get_sync(uuid2, incoming=False), -1) - self.assertEquals(broker.get_sync(uuid3, incoming=False), -1) + self.assertEqual(broker.get_sync(uuid2), 1) + self.assertEqual(broker.get_sync(uuid3), 2) + self.assertEqual(broker.get_sync(uuid2, incoming=False), -1) + self.assertEqual(broker.get_sync(uuid3, incoming=False), -1) broker.merge_syncs([{'sync_point': 3, 'remote_id': uuid2}, {'sync_point': 4, 'remote_id': uuid3}], incoming=False) - self.assertEquals(broker.get_sync(uuid2, incoming=False), 3) - self.assertEquals(broker.get_sync(uuid3, incoming=False), 4) - self.assertEquals(broker.get_sync(uuid2), 1) - self.assertEquals(broker.get_sync(uuid3), 2) + self.assertEqual(broker.get_sync(uuid2, incoming=False), 3) + self.assertEqual(broker.get_sync(uuid3, incoming=False), 4) + self.assertEqual(broker.get_sync(uuid2), 1) + self.assertEqual(broker.get_sync(uuid3), 2) broker.merge_syncs([{'sync_point': 5, 'remote_id': uuid2}]) - self.assertEquals(broker.get_sync(uuid2), 5) + self.assertEqual(broker.get_sync(uuid2), 5) def test_get_replication_info(self): self.get_replication_info_tester(metadata=False) @@ -1019,7 +1019,7 @@ class TestDatabaseBroker(unittest.TestCase): put_timestamp = normalize_timestamp(2) broker.initialize(put_timestamp) info = broker.get_replication_info() - self.assertEquals(info, { + self.assertEqual(info, { 'account': broker.account, 'count': 0, 'hash': '00000000000000000000000000000000', 'created_at': broker_creation, 'put_timestamp': put_timestamp, @@ -1032,7 +1032,7 @@ class TestDatabaseBroker(unittest.TestCase): ''', (insert_timestamp,)) conn.commit() info = broker.get_replication_info() - self.assertEquals(info, { + self.assertEqual(info, { 'account': broker.account, 'count': 1, 'hash': 'bdc4c93f574b0d8c2911a27ce9dd38ba', 'created_at': broker_creation, 'put_timestamp': put_timestamp, @@ -1042,7 +1042,7 @@ class TestDatabaseBroker(unittest.TestCase): conn.execute('DELETE FROM test') conn.commit() info = broker.get_replication_info() - self.assertEquals(info, { + self.assertEqual(info, { 'account': broker.account, 'count': 0, 'hash': '00000000000000000000000000000000', 'created_at': broker_creation, 'put_timestamp': put_timestamp, @@ -1062,59 +1062,59 @@ class TestDatabaseBroker(unittest.TestCase): first_value = '1' broker.update_metadata({'First': [first_value, first_timestamp]}) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) # Add our second item second_timestamp = normalize_timestamp(2) second_value = '2' broker.update_metadata({'Second': [second_value, second_timestamp]}) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) self.assertTrue('Second' in broker.metadata) - self.assertEquals(broker.metadata['Second'], - [second_value, second_timestamp]) + self.assertEqual(broker.metadata['Second'], + [second_value, second_timestamp]) # Update our first item first_timestamp = normalize_timestamp(3) first_value = '1b' broker.update_metadata({'First': [first_value, first_timestamp]}) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) self.assertTrue('Second' in broker.metadata) - self.assertEquals(broker.metadata['Second'], - [second_value, second_timestamp]) + self.assertEqual(broker.metadata['Second'], + [second_value, second_timestamp]) # Delete our second item (by setting to empty string) second_timestamp = normalize_timestamp(4) second_value = '' broker.update_metadata({'Second': [second_value, second_timestamp]}) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) self.assertTrue('Second' in broker.metadata) - self.assertEquals(broker.metadata['Second'], - [second_value, second_timestamp]) + self.assertEqual(broker.metadata['Second'], + [second_value, second_timestamp]) # Reclaim at point before second item was deleted reclaim(broker, normalize_timestamp(3)) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) self.assertTrue('Second' in broker.metadata) - self.assertEquals(broker.metadata['Second'], - [second_value, second_timestamp]) + self.assertEqual(broker.metadata['Second'], + [second_value, second_timestamp]) # Reclaim at point second item was deleted reclaim(broker, normalize_timestamp(4)) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) self.assertTrue('Second' in broker.metadata) - self.assertEquals(broker.metadata['Second'], - [second_value, second_timestamp]) + self.assertEqual(broker.metadata['Second'], + [second_value, second_timestamp]) # Reclaim after point second item was deleted reclaim(broker, normalize_timestamp(5)) self.assertTrue('First' in broker.metadata) - self.assertEquals(broker.metadata['First'], - [first_value, first_timestamp]) + self.assertEqual(broker.metadata['First'], + [first_value, first_timestamp]) self.assertTrue('Second' not in broker.metadata) @patch.object(DatabaseBroker, 'validate_metadata') @@ -1218,7 +1218,7 @@ class TestDatabaseBroker(unittest.TestCase): try: broker.possibly_quarantine(*sys.exc_info()) except Exception as exc: - self.assertEquals( + self.assertEqual( str(exc), 'Quarantined %s to %s due to disk error ' 'while accessing database' % diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py index 03c3864350..b61dacf02d 100644 --- a/test/unit/common/test_db_replicator.py +++ b/test/unit/common/test_db_replicator.py @@ -287,8 +287,8 @@ class TestDBReplicator(unittest.TestCase): logging.getLogger()) def req(method, path, body, headers): - self.assertEquals(method, 'REPLICATE') - self.assertEquals(headers['Content-Type'], 'application/json') + self.assertEqual(method, 'REPLICATE') + self.assertEqual(headers['Content-Type'], 'application/json') class Resp(object): def read(self): @@ -296,21 +296,21 @@ class TestDBReplicator(unittest.TestCase): resp = Resp() conn.request = req conn.getresponse = lambda *args: resp - self.assertEquals(conn.replicate(1, 2, 3), resp) + self.assertEqual(conn.replicate(1, 2, 3), resp) def other_req(method, path, body, headers): raise Exception('blah') conn.request = other_req - self.assertEquals(conn.replicate(1, 2, 3), None) + self.assertEqual(conn.replicate(1, 2, 3), None) def test_rsync_file(self): replicator = TestReplicator({}) with _mock_process(-1): - self.assertEquals( + self.assertEqual( False, replicator._rsync_file('/some/file', 'remote:/some/file')) with _mock_process(0): - self.assertEquals( + self.assertEqual( True, replicator._rsync_file('/some/file', 'remote:/some/file')) @@ -414,11 +414,11 @@ class TestDBReplicator(unittest.TestCase): different_region=False): self_._rsync_file_call_count += 1 if self_._rsync_file_call_count == 1: - self.assertEquals(True, whole_file) - self.assertEquals(False, self_.broker.locked) + self.assertEqual(True, whole_file) + self.assertEqual(False, self_.broker.locked) elif self_._rsync_file_call_count == 2: - self.assertEquals(False, whole_file) - self.assertEquals(True, self_.broker.locked) + self.assertEqual(False, whole_file) + self.assertEqual(True, self_.broker.locked) else: raise RuntimeError('_rsync_file() called too many times') return True @@ -430,7 +430,7 @@ class TestDBReplicator(unittest.TestCase): fake_device = {'ip': '127.0.0.1', 'replication_ip': '127.0.0.1', 'device': 'sda1'} replicator._rsync_db(broker, fake_device, ReplHttp(), 'abcd') - self.assertEquals(2, replicator._rsync_file_call_count) + self.assertEqual(2, replicator._rsync_file_call_count) # with new mtime with patch('os.path.exists', lambda *args: False): @@ -441,19 +441,19 @@ class TestDBReplicator(unittest.TestCase): 'replication_ip': '127.0.0.1', 'device': 'sda1'} replicator._rsync_db(broker, fake_device, ReplHttp(), 'abcd') - self.assertEquals(2, replicator._rsync_file_call_count) + self.assertEqual(2, replicator._rsync_file_call_count) def test_in_sync(self): replicator = TestReplicator({}) - self.assertEquals(replicator._in_sync( + self.assertEqual(replicator._in_sync( {'id': 'a', 'point': 0, 'max_row': 0, 'hash': 'b'}, {'id': 'a', 'point': -1, 'max_row': 0, 'hash': 'b'}, FakeBroker(), -1), True) - self.assertEquals(replicator._in_sync( + self.assertEqual(replicator._in_sync( {'id': 'a', 'point': -1, 'max_row': 0, 'hash': 'b'}, {'id': 'a', 'point': -1, 'max_row': 10, 'hash': 'b'}, FakeBroker(), -1), True) - self.assertEquals(bool(replicator._in_sync( + self.assertEqual(bool(replicator._in_sync( {'id': 'a', 'point': -1, 'max_row': 0, 'hash': 'c'}, {'id': 'a', 'point': -1, 'max_row': 10, 'hash': 'd'}, FakeBroker(), -1)), False) @@ -483,9 +483,9 @@ class TestDBReplicator(unittest.TestCase): self.assertEqual(replicator.port, 6000) def mock_ismount(path): - self.assertEquals(path, - os.path.join(replicator.root, - replicator.ring.devs[0]['device'])) + self.assertEqual(path, + os.path.join(replicator.root, + replicator.ring.devs[0]['device'])) return False self._patch(patch.object, db_replicator, 'ismount', mock_ismount) @@ -504,16 +504,16 @@ class TestDBReplicator(unittest.TestCase): self.assertEqual(replicator.port, 6000) def mock_unlink_older_than(path, mtime): - self.assertEquals(path, - os.path.join(replicator.root, - replicator.ring.devs[0]['device'], - 'tmp')) + self.assertEqual(path, + os.path.join(replicator.root, + replicator.ring.devs[0]['device'], + 'tmp')) self.assertTrue(time.time() - replicator.reclaim_age >= mtime) def mock_spawn_n(fn, part, object_file, node_id): - self.assertEquals('123', part) - self.assertEquals('/srv/node/sda/c.db', object_file) - self.assertEquals(1, node_id) + self.assertEqual('123', part) + self.assertEqual('/srv/node/sda/c.db', object_file) + self.assertEqual(1, node_id) self._patch(patch.object, db_replicator, 'whataremyips', lambda *a, **kw: ['1.1.1.1']) @@ -562,7 +562,7 @@ class TestDBReplicator(unittest.TestCase): replicator = TestReplicator({}) replicator.delete_db = self.stub_delete_db replicator._replicate_object('0', '/path/to/file', 'node_id') - self.assertEquals([], self.delete_db_calls) + self.assertEqual([], self.delete_db_calls) def test_replicate_object_quarantine(self): replicator = TestReplicator({}) @@ -574,12 +574,12 @@ class TestDBReplicator(unittest.TestCase): def mock_renamer(was, new, fsync=False, cause_colision=False): if cause_colision and '-' not in new: raise OSError(errno.EEXIST, "File already exists") - self.assertEquals('/a/b/c/d/e', was) + self.assertEqual('/a/b/c/d/e', was) if '-' in new: self.assertTrue( new.startswith('/a/quarantined/containers/e-')) else: - self.assertEquals('/a/quarantined/containers/e', new) + self.assertEqual('/a/quarantined/containers/e', new) def mock_renamer_error(was, new, fsync): return mock_renamer(was, new, fsync, cause_colision=True) @@ -598,13 +598,13 @@ class TestDBReplicator(unittest.TestCase): replicator._replicate_object('0', '/path/to/file', 'node_id') finally: replicator.brokerclass.stub_replication_info = None - self.assertEquals(['/path/to/file'], self.delete_db_calls) + self.assertEqual(['/path/to/file'], self.delete_db_calls) def test_replicate_object_delete_because_not_shouldbehere(self): replicator = TestReplicator({}) replicator.delete_db = self.stub_delete_db replicator._replicate_object('0', '/path/to/file', 'node_id') - self.assertEquals(['/path/to/file'], self.delete_db_calls) + self.assertEqual(['/path/to/file'], self.delete_db_calls) def test_replicate_account_out_of_place(self): replicator = TestReplicator({}, logger=unit.FakeLogger()) @@ -718,28 +718,28 @@ class TestDBReplicator(unittest.TestCase): def test_dispatch_no_arg_pop(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) response = rpc.dispatch(('a',), 'arg') - self.assertEquals('Invalid object type', response.body) - self.assertEquals(400, response.status_int) + self.assertEqual('Invalid object type', response.body) + self.assertEqual(400, response.status_int) def test_dispatch_drive_not_mounted(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, True) def mock_ismount(path): - self.assertEquals('/drive', path) + self.assertEqual('/drive', path) return False self._patch(patch.object, db_replicator, 'ismount', mock_ismount) response = rpc.dispatch(('drive', 'part', 'hash'), ['method']) - self.assertEquals('507 drive is not mounted', response.status) - self.assertEquals(507, response.status_int) + self.assertEqual('507 drive is not mounted', response.status) + self.assertEqual(507, response.status_int) def test_dispatch_unexpected_operation_db_does_not_exist(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) def mock_mkdirs(path): - self.assertEquals('/drive/tmp', path) + self.assertEqual('/drive/tmp', path) self._patch(patch.object, db_replicator, 'mkdirs', mock_mkdirs) @@ -748,8 +748,8 @@ class TestDBReplicator(unittest.TestCase): mock_os.path.exists.return_value = False response = rpc.dispatch(('drive', 'part', 'hash'), ['unexpected']) - self.assertEquals('404 Not Found', response.status) - self.assertEquals(404, response.status_int) + self.assertEqual('404 Not Found', response.status) + self.assertEqual(404, response.status_int) def test_dispatch_operation_unexpected(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -757,7 +757,7 @@ class TestDBReplicator(unittest.TestCase): self._patch(patch.object, db_replicator, 'mkdirs', lambda *args: True) def unexpected_method(broker, args): - self.assertEquals(FakeBroker, broker.__class__) + self.assertEqual(FakeBroker, broker.__class__) self.assertEqual(['arg1', 'arg2'], args) return 'unexpected-called' @@ -770,7 +770,7 @@ class TestDBReplicator(unittest.TestCase): ['unexpected', 'arg1', 'arg2']) mock_os.path.exists.assert_called_with('/part/ash/hash/hash.db') - self.assertEquals('unexpected-called', response) + self.assertEqual('unexpected-called', response) def test_dispatch_operation_rsync_then_merge(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -784,10 +784,10 @@ class TestDBReplicator(unittest.TestCase): ['rsync_then_merge', 'arg1', 'arg2']) expected_calls = [call('/part/ash/hash/hash.db'), call('/drive/tmp/arg1')] - self.assertEquals(mock_os.path.exists.call_args_list, - expected_calls) - self.assertEquals('204 No Content', response.status) - self.assertEquals(204, response.status_int) + self.assertEqual(mock_os.path.exists.call_args_list, + expected_calls) + self.assertEqual('204 No Content', response.status) + self.assertEqual(204, response.status_int) def test_dispatch_operation_complete_rsync(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -801,10 +801,10 @@ class TestDBReplicator(unittest.TestCase): ['complete_rsync', 'arg1', 'arg2']) expected_calls = [call('/part/ash/hash/hash.db'), call('/drive/tmp/arg1')] - self.assertEquals(mock_os.path.exists.call_args_list, - expected_calls) - self.assertEquals('204 No Content', response.status) - self.assertEquals(204, response.status_int) + self.assertEqual(mock_os.path.exists.call_args_list, + expected_calls) + self.assertEqual('204 No Content', response.status) + self.assertEqual(204, response.status_int) def test_rsync_then_merge_db_does_not_exist(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -815,8 +815,8 @@ class TestDBReplicator(unittest.TestCase): response = rpc.rsync_then_merge('drive', '/data/db.db', ('arg1', 'arg2')) mock_os.path.exists.assert_called_with('/data/db.db') - self.assertEquals('404 Not Found', response.status) - self.assertEquals(404, response.status_int) + self.assertEqual('404 Not Found', response.status) + self.assertEqual(404, response.status_int) def test_rsync_then_merge_old_does_not_exist(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -827,17 +827,17 @@ class TestDBReplicator(unittest.TestCase): response = rpc.rsync_then_merge('drive', '/data/db.db', ('arg1', 'arg2')) expected_calls = [call('/data/db.db'), call('/drive/tmp/arg1')] - self.assertEquals(mock_os.path.exists.call_args_list, - expected_calls) - self.assertEquals('404 Not Found', response.status) - self.assertEquals(404, response.status_int) + self.assertEqual(mock_os.path.exists.call_args_list, + expected_calls) + self.assertEqual('404 Not Found', response.status) + self.assertEqual(404, response.status_int) def test_rsync_then_merge_with_objects(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) def mock_renamer(old, new): - self.assertEquals('/drive/tmp/arg1', old) - self.assertEquals('/data/db.db', new) + self.assertEqual('/drive/tmp/arg1', old) + self.assertEqual('/data/db.db', new) self._patch(patch.object, db_replicator, 'renamer', mock_renamer) @@ -846,8 +846,8 @@ class TestDBReplicator(unittest.TestCase): mock_os.path.exists.return_value = True response = rpc.rsync_then_merge('drive', '/data/db.db', ['arg1', 'arg2']) - self.assertEquals('204 No Content', response.status) - self.assertEquals(204, response.status_int) + self.assertEqual('204 No Content', response.status) + self.assertEqual(204, response.status_int) def test_complete_rsync_db_does_not_exist(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -858,8 +858,8 @@ class TestDBReplicator(unittest.TestCase): response = rpc.complete_rsync('drive', '/data/db.db', ['arg1', 'arg2']) mock_os.path.exists.assert_called_with('/data/db.db') - self.assertEquals('404 Not Found', response.status) - self.assertEquals(404, response.status_int) + self.assertEqual('404 Not Found', response.status) + self.assertEqual(404, response.status_int) def test_complete_rsync_old_file_does_not_exist(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -870,10 +870,10 @@ class TestDBReplicator(unittest.TestCase): response = rpc.complete_rsync('drive', '/data/db.db', ['arg1', 'arg2']) expected_calls = [call('/data/db.db'), call('/drive/tmp/arg1')] - self.assertEquals(expected_calls, - mock_os.path.exists.call_args_list) - self.assertEquals('404 Not Found', response.status) - self.assertEquals(404, response.status_int) + self.assertEqual(expected_calls, + mock_os.path.exists.call_args_list) + self.assertEqual('404 Not Found', response.status) + self.assertEqual(404, response.status_int) def test_complete_rsync_rename(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -881,12 +881,12 @@ class TestDBReplicator(unittest.TestCase): def mock_exists(path): if path == '/data/db.db': return False - self.assertEquals('/drive/tmp/arg1', path) + self.assertEqual('/drive/tmp/arg1', path) return True def mock_renamer(old, new): - self.assertEquals('/drive/tmp/arg1', old) - self.assertEquals('/data/db.db', new) + self.assertEqual('/drive/tmp/arg1', old) + self.assertEqual('/data/db.db', new) self._patch(patch.object, db_replicator, 'renamer', mock_renamer) @@ -895,8 +895,8 @@ class TestDBReplicator(unittest.TestCase): mock_os.path.exists.side_effect = [False, True] response = rpc.complete_rsync('drive', '/data/db.db', ['arg1', 'arg2']) - self.assertEquals('204 No Content', response.status) - self.assertEquals(204, response.status_int) + self.assertEqual('204 No Content', response.status) + self.assertEqual(204, response.status_int) def test_replicator_sync_with_broker_replication_missing_table(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -908,8 +908,8 @@ class TestDBReplicator(unittest.TestCase): def mock_quarantine_db(object_file, server_type): called.append(True) - self.assertEquals(broker.db_file, object_file) - self.assertEquals(broker.db_type, server_type) + self.assertEqual(broker.db_file, object_file) + self.assertEqual(broker.db_type, server_type) self._patch(patch.object, db_replicator, 'quarantine_db', mock_quarantine_db) @@ -918,8 +918,8 @@ class TestDBReplicator(unittest.TestCase): 'created_at', 'put_timestamp', 'delete_timestamp', 'metadata')) - self.assertEquals('404 Not Found', response.status) - self.assertEquals(404, response.status_int) + self.assertEqual('404 Not Found', response.status) + self.assertEqual(404, response.status_int) self.assertEqual(called, [True]) errors = rpc.logger.get_lines_for_level('error') self.assertEqual(errors, @@ -935,14 +935,14 @@ class TestDBReplicator(unittest.TestCase): 'delete_timestamp', '{"meta1": "data1", "meta2": "data2"}')) - self.assertEquals({'meta1': 'data1', 'meta2': 'data2'}, - broker.metadata) - self.assertEquals('created_at', broker.created_at) - self.assertEquals('put_timestamp', broker.put_timestamp) - self.assertEquals('delete_timestamp', broker.delete_timestamp) + self.assertEqual({'meta1': 'data1', 'meta2': 'data2'}, + broker.metadata) + self.assertEqual('created_at', broker.created_at) + self.assertEqual('put_timestamp', broker.put_timestamp) + self.assertEqual('delete_timestamp', broker.delete_timestamp) - self.assertEquals('200 OK', response.status) - self.assertEquals(200, response.status_int) + self.assertEqual('200 OK', response.status) + self.assertEqual(200, response.status_int) def test_rsync_then_merge(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) @@ -953,14 +953,14 @@ class TestDBReplicator(unittest.TestCase): fake_broker = FakeBroker() args = ('a', 'b') rpc.merge_items(fake_broker, args) - self.assertEquals(fake_broker.args, args) + self.assertEqual(fake_broker.args, args) def test_merge_syncs(self): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) fake_broker = FakeBroker() args = ('a', 'b') rpc.merge_syncs(fake_broker, args) - self.assertEquals(fake_broker.args, (args[0],)) + self.assertEqual(fake_broker.args, (args[0],)) def test_complete_rsync_with_bad_input(self): drive = '/some/root' @@ -969,10 +969,10 @@ class TestDBReplicator(unittest.TestCase): rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False) resp = rpc.complete_rsync(drive, db_file, args) self.assertTrue(isinstance(resp, HTTPException)) - self.assertEquals(404, resp.status_int) + self.assertEqual(404, resp.status_int) resp = rpc.complete_rsync(drive, 'new_db_file', args) self.assertTrue(isinstance(resp, HTTPException)) - self.assertEquals(404, resp.status_int) + self.assertEqual(404, resp.status_int) def test_complete_rsync(self): drive = mkdtemp() @@ -986,7 +986,7 @@ class TestDBReplicator(unittest.TestCase): fp.write('void') fp.close resp = rpc.complete_rsync(drive, new_file, args) - self.assertEquals(204, resp.status_int) + self.assertEqual(204, resp.status_int) finally: rmtree(drive) @@ -1076,7 +1076,7 @@ class TestDBReplicator(unittest.TestCase): results = list(db_replicator.roundrobin_datadirs(datadirs)) # The results show that the .db files are returned, the devices # interleaved. - self.assertEquals(results, [ + self.assertEqual(results, [ ('123', '/srv/node/sda/containers/123/abc/' '00000000000000000000000000000abc/' '00000000000000000000000000000abc.db', 1), @@ -1090,7 +1090,7 @@ class TestDBReplicator(unittest.TestCase): '22222222222222222222222222222ghi/' '22222222222222222222222222222ghi.db', 2)]) # The listdir calls show that we only listdir the dirs - self.assertEquals(listdir_calls, [ + self.assertEqual(listdir_calls, [ '/srv/node/sda/containers', '/srv/node/sda/containers/123', '/srv/node/sda/containers/123/abc', @@ -1105,7 +1105,7 @@ class TestDBReplicator(unittest.TestCase): '/srv/node/sdb/containers/9999']) # The isdir calls show that we did ask about the things pretending # to be files at various levels. - self.assertEquals(isdir_calls, [ + self.assertEqual(isdir_calls, [ '/srv/node/sda/containers/123', '/srv/node/sda/containers/123/abc', ('/srv/node/sda/containers/123/abc/' @@ -1140,7 +1140,7 @@ class TestDBReplicator(unittest.TestCase): '/srv/node/sdb/containers/9999']) # The exists calls are the .db files we looked for as we walked the # structure. - self.assertEquals(exists_calls, [ + self.assertEqual(exists_calls, [ ('/srv/node/sda/containers/123/abc/' '00000000000000000000000000000abc/' '00000000000000000000000000000abc.db'), @@ -1154,12 +1154,12 @@ class TestDBReplicator(unittest.TestCase): '22222222222222222222222222222ghi/' '22222222222222222222222222222ghi.db')]) # Shows that we called shuffle twice, once for each device. - self.assertEquals( + self.assertEqual( shuffle_calls, [['123', '456', '789', '9999'], ['123', '456', '789', '9999']]) # Shows that we called removed the two empty partition directories. - self.assertEquals( + self.assertEqual( rmdir_calls, ['/srv/node/sda/containers/9999', '/srv/node/sdb/containers/9999']) finally: @@ -1204,7 +1204,7 @@ class TestReplToNode(unittest.TestCase): rinfo = {"id": 3, "point": -1, "max_row": 5, "hash": "c"} self.http = ReplHttp(simplejson.dumps(rinfo)) local_sync = self.broker.get_sync() - self.assertEquals(self.replicator._repl_to_node( + self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) self.replicator._usync_db.assert_has_calls([ mock.call(max(rinfo['point'], local_sync), self.broker, @@ -1215,7 +1215,7 @@ class TestReplToNode(unittest.TestCase): rinfo = {"id": 3, "point": -1, "max_row": 4, "hash": "c"} self.http = ReplHttp(simplejson.dumps(rinfo)) self.broker.get_sync() - self.assertEquals(self.replicator._repl_to_node( + self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) self.replicator.logger.increment.assert_has_calls([ mock.call.increment('remote_merges') @@ -1232,14 +1232,14 @@ class TestReplToNode(unittest.TestCase): rinfo = {"id": 3, "point": -1, "max_row": 10, "hash": "b"} self.http = ReplHttp(simplejson.dumps(rinfo)) self.broker.get_sync() - self.assertEquals(self.replicator._repl_to_node( + self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) - self.assertEquals(self.replicator._rsync_db.call_count, 0) - self.assertEquals(self.replicator._usync_db.call_count, 0) + self.assertEqual(self.replicator._rsync_db.call_count, 0) + self.assertEqual(self.replicator._usync_db.call_count, 0) def test_repl_to_node_not_found(self): self.http = ReplHttp('{"id": 3, "point": -1}', set_status=404) - self.assertEquals(self.replicator._repl_to_node( + self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info, False), True) self.replicator.logger.increment.assert_has_calls([ mock.call.increment('rsyncs') @@ -1258,12 +1258,12 @@ class TestReplToNode(unittest.TestCase): def test_repl_to_node_300_status(self): self.http = ReplHttp('{"id": 3, "point": -1}', set_status=300) - self.assertEquals(self.replicator._repl_to_node( + self.assertEqual(self.replicator._repl_to_node( self.fake_node, FakeBroker(), '0', self.fake_info), None) def test_repl_to_node_not_response(self): self.http = mock.Mock(replicate=mock.Mock(return_value=None)) - self.assertEquals(self.replicator._repl_to_node( + self.assertEqual(self.replicator._repl_to_node( self.fake_node, FakeBroker(), '0', self.fake_info), False) diff --git a/test/unit/common/test_internal_client.py b/test/unit/common/test_internal_client.py index 66c9d04a22..d4b7c1521a 100644 --- a/test/unit/common/test_internal_client.py +++ b/test/unit/common/test_internal_client.py @@ -90,9 +90,9 @@ class GetMetadataInternalClient(internal_client.InternalClient): def _get_metadata(self, path, metadata_prefix, acceptable_statuses=None, headers=None): self.get_metadata_called += 1 - self.test.assertEquals(self.path, path) - self.test.assertEquals(self.metadata_prefix, metadata_prefix) - self.test.assertEquals(self.acceptable_statuses, acceptable_statuses) + self.test.assertEqual(self.path, path) + self.test.assertEqual(self.metadata_prefix, metadata_prefix) + self.test.assertEqual(self.acceptable_statuses, acceptable_statuses) return self.metadata @@ -111,10 +111,10 @@ class SetMetadataInternalClient(internal_client.InternalClient): self, path, metadata, metadata_prefix='', acceptable_statuses=None): self.set_metadata_called += 1 - self.test.assertEquals(self.path, path) - self.test.assertEquals(self.metadata_prefix, metadata_prefix) - self.test.assertEquals(self.metadata, metadata) - self.test.assertEquals(self.acceptable_statuses, acceptable_statuses) + self.test.assertEqual(self.path, path) + self.test.assertEqual(self.metadata_prefix, metadata_prefix) + self.test.assertEqual(self.metadata, metadata) + self.test.assertEqual(self.acceptable_statuses, acceptable_statuses) class IterInternalClient(internal_client.InternalClient): @@ -129,10 +129,10 @@ class IterInternalClient(internal_client.InternalClient): def _iter_items( self, path, marker='', end_marker='', acceptable_statuses=None): - self.test.assertEquals(self.path, path) - self.test.assertEquals(self.marker, marker) - self.test.assertEquals(self.end_marker, end_marker) - self.test.assertEquals(self.acceptable_statuses, acceptable_statuses) + self.test.assertEqual(self.path, path) + self.test.assertEqual(self.marker, marker) + self.test.assertEqual(self.end_marker, end_marker) + self.test.assertEqual(self.acceptable_statuses, acceptable_statuses) for item in self.items: yield item @@ -145,7 +145,7 @@ class TestCompressingfileReader(unittest.TestCase): self.args = args def method(self, *args): - self.test.assertEquals(self.args, args) + self.test.assertEqual(self.args, args) return self try: @@ -158,12 +158,12 @@ class TestCompressingfileReader(unittest.TestCase): f = StringIO('') fobj = internal_client.CompressingFileReader(f) - self.assertEquals(f, fobj._f) - self.assertEquals(compressobj, fobj._compressor) - self.assertEquals(False, fobj.done) - self.assertEquals(True, fobj.first) - self.assertEquals(0, fobj.crc32) - self.assertEquals(0, fobj.total_size) + self.assertEqual(f, fobj._f) + self.assertEqual(compressobj, fobj._compressor) + self.assertEqual(False, fobj.done) + self.assertEqual(True, fobj.first) + self.assertEqual(0, fobj.crc32) + self.assertEqual(0, fobj.total_size) finally: internal_client.compressobj = old_compressobj @@ -177,7 +177,7 @@ class TestCompressingfileReader(unittest.TestCase): for chunk in fobj.read(): data += d.decompress(chunk) - self.assertEquals(exp_data, data) + self.assertEqual(exp_data, data) def test_seek(self): exp_data = 'abcdefghijklmnopqrstuvwxyz' @@ -194,7 +194,7 @@ class TestCompressingfileReader(unittest.TestCase): d = zlib.decompressobj(16 + zlib.MAX_WBITS) for chunk in fobj.read(): data += d.decompress(chunk) - self.assertEquals(exp_data, data) + self.assertEqual(exp_data, data) def test_seek_not_implemented_exception(self): fobj = internal_client.CompressingFileReader( @@ -249,7 +249,7 @@ class TestInternalClient(unittest.TestCase): object_ring) self.assertEqual(object_ring.serialized_path, object_ring_path) - self.assertEquals(client.auto_create_account_prefix, '-') + self.assertEqual(client.auto_create_account_prefix, '-') def test_init(self): class App(object): @@ -260,7 +260,7 @@ class TestInternalClient(unittest.TestCase): def load(self, uri, allow_modify_pipeline=True): self.load_called += 1 - self.test.assertEquals(conf_path, uri) + self.test.assertEqual(conf_path, uri) self.test.assertFalse(allow_modify_pipeline) return self @@ -278,10 +278,10 @@ class TestInternalClient(unittest.TestCase): finally: internal_client.loadapp = old_loadapp - self.assertEquals(1, app.load_called) - self.assertEquals(app, client.app) - self.assertEquals(user_agent, client.user_agent) - self.assertEquals(request_tries, client.request_tries) + self.assertEqual(1, app.load_called) + self.assertEqual(app, client.app) + self.assertEqual(user_agent, client.user_agent) + self.assertEqual(request_tries, client.request_tries) def test_make_request_sets_user_agent(self): class InternalClient(internal_client.InternalClient): @@ -292,7 +292,7 @@ class TestInternalClient(unittest.TestCase): self.request_tries = 1 def fake_app(self, env, start_response): - self.test.assertEquals(self.user_agent, env['HTTP_USER_AGENT']) + self.test.assertEqual(self.user_agent, env['HTTP_USER_AGENT']) start_response('200 Ok', [('Content-Length', '0')]) return [] @@ -320,7 +320,7 @@ class TestInternalClient(unittest.TestCase): def sleep(self, seconds): self.sleep_called += 1 - self.test.assertEquals(2 ** (self.sleep_called), seconds) + self.test.assertEqual(2 ** (self.sleep_called), seconds) client = InternalClient(self) @@ -332,8 +332,8 @@ class TestInternalClient(unittest.TestCase): finally: internal_client.sleep = old_sleep - self.assertEquals(3, client.sleep_called) - self.assertEquals(4, client.tries) + self.assertEqual(3, client.sleep_called) + self.assertEqual(4, client.tries) def test_base_request_timeout(self): # verify that base_request passes timeout arg on to urlopen @@ -351,7 +351,7 @@ class TestInternalClient(unittest.TestCase): _, resp_body = sc.base_request('GET', timeout=timeout) mock_urlopen.assert_called_once_with(mock.ANY, timeout=timeout) # sanity check - self.assertEquals(body, resp_body) + self.assertEqual(body, resp_body) def test_make_request_method_path_headers(self): class InternalClient(internal_client.InternalClient): @@ -370,12 +370,12 @@ class TestInternalClient(unittest.TestCase): for method in 'GET PUT HEAD'.split(): client.make_request(method, '/', {}, (200,)) - self.assertEquals(client.env['REQUEST_METHOD'], method) + self.assertEqual(client.env['REQUEST_METHOD'], method) for path in '/one /two/three'.split(): client.make_request('GET', path, {'X-Test': path}, (200,)) - self.assertEquals(client.env['PATH_INFO'], path) - self.assertEquals(client.env['HTTP_X_TEST'], path) + self.assertEqual(client.env['PATH_INFO'], path) + self.assertEqual(client.env['HTTP_X_TEST'], path) def test_make_request_codes(self): class InternalClient(internal_client.InternalClient): @@ -403,12 +403,12 @@ class TestInternalClient(unittest.TestCase): client.make_request('GET', '/', {}, (400,)) except Exception as err: pass - self.assertEquals(200, err.resp.status_int) + self.assertEqual(200, err.resp.status_int) try: client.make_request('GET', '/', {}, (201,)) except Exception as err: pass - self.assertEquals(200, err.resp.status_int) + self.assertEqual(200, err.resp.status_int) try: client.make_request('GET', '/', {}, (111,)) except Exception as err: @@ -426,8 +426,8 @@ class TestInternalClient(unittest.TestCase): def seek(self, offset, whence=0): self.seek_called += 1 - self.test.assertEquals(0, offset) - self.test.assertEquals(0, whence) + self.test.assertEqual(0, offset) + self.test.assertEqual(0, whence) class InternalClient(internal_client.InternalClient): def __init__(self): @@ -449,11 +449,11 @@ class TestInternalClient(unittest.TestCase): client.make_request('PUT', '/', {}, (2,), fobj) except Exception as err: pass - self.assertEquals(404, err.resp.status_int) + self.assertEqual(404, err.resp.status_int) finally: internal_client.sleep = old_sleep - self.assertEquals(client.request_tries, fobj.seek_called) + self.assertEqual(client.request_tries, fobj.seek_called) def test_make_request_request_exception(self): class InternalClient(internal_client.InternalClient): @@ -491,10 +491,10 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals('HEAD', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals((2,), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('HEAD', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual((2,), acceptable_statuses) + self.test.assertEqual(None, body_file) return Response(self.resp_headers) path = 'some_path' @@ -514,8 +514,8 @@ class TestInternalClient(unittest.TestCase): client = InternalClient(self, path, resp_headers) metadata = client._get_metadata(path, metadata_prefix) - self.assertEquals(exp_metadata, metadata) - self.assertEquals(1, client.make_request_called) + self.assertEqual(exp_metadata, metadata) + self.assertEqual(1, client.make_request_called) def test_get_metadata_invalid_status(self): class FakeApp(object): @@ -542,7 +542,7 @@ class TestInternalClient(unittest.TestCase): path = make_path(account, container, obj) c = InternalClient() - self.assertEquals(path, c.make_path(account, container, obj)) + self.assertEqual(path, c.make_path(account, container, obj)) def test_make_path_exception(self): c = InternalClient() @@ -572,7 +572,7 @@ class TestInternalClient(unittest.TestCase): client = InternalClient(self, responses) for item in client._iter_items('/'): items.append(item) - self.assertEquals(exp_items, items) + self.assertEqual(exp_items, items) exp_items = [] responses = [] @@ -588,7 +588,7 @@ class TestInternalClient(unittest.TestCase): client = InternalClient(self, responses) for item in client._iter_items('/'): items.append(item) - self.assertEquals(exp_items, items) + self.assertEqual(exp_items, items) def test_iter_items_with_markers(self): class Response(object): @@ -606,7 +606,7 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): exp_path = self.paths.pop(0) - self.test.assertEquals(exp_path, path) + self.test.assertEqual(exp_path, path) return self.responses.pop(0) paths = [ @@ -626,7 +626,7 @@ class TestInternalClient(unittest.TestCase): for item in client._iter_items('/', marker='start', end_marker='end'): items.append(item['name'].encode('utf8')) - self.assertEquals('one\xc3\xa9 two'.split(), items) + self.assertEqual('one\xc3\xa9 two'.split(), items) def test_set_metadata(self): class InternalClient(internal_client.InternalClient): @@ -640,11 +640,11 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals('POST', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals(self.exp_headers, headers) - self.test.assertEquals((2,), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('POST', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual(self.exp_headers, headers) + self.test.assertEqual((2,), acceptable_statuses) + self.test.assertEqual(None, body_file) path = 'some_path' metadata_prefix = 'some_key-' @@ -661,7 +661,7 @@ class TestInternalClient(unittest.TestCase): client = InternalClient(self, path, exp_headers) client._set_metadata(path, metadata, metadata_prefix) - self.assertEquals(1, client.make_request_called) + self.assertEqual(1, client.make_request_called) def test_iter_containers(self): account, container, obj = path_parts() @@ -677,7 +677,7 @@ class TestInternalClient(unittest.TestCase): account, marker, end_marker, acceptable_statuses=acceptable_statuses): ret_items.append(container) - self.assertEquals(items, ret_items) + self.assertEqual(items, ret_items) def test_get_account_info(self): class Response(object): @@ -697,11 +697,11 @@ class TestInternalClient(unittest.TestCase): def make_request( self, method, path, headers, acceptable_statuses, body_file=None): - self.test.assertEquals('HEAD', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals({}, headers) - self.test.assertEquals((2, 404), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('HEAD', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual({}, headers) + self.test.assertEqual((2, 404), acceptable_statuses) + self.test.assertEqual(None, body_file) return self.resp account, container, obj = path_parts() @@ -709,7 +709,7 @@ class TestInternalClient(unittest.TestCase): containers, objects = 10, 100 client = InternalClient(self, path, Response(containers, objects)) info = client.get_account_info(account) - self.assertEquals((containers, objects), info) + self.assertEqual((containers, objects), info) def test_get_account_info_404(self): class Response(object): @@ -732,7 +732,7 @@ class TestInternalClient(unittest.TestCase): client = InternalClient() info = client.get_account_info('some_account') - self.assertEquals((0, 0), info) + self.assertEqual((0, 0), info) def test_get_account_metadata(self): account, container, obj = path_parts() @@ -743,8 +743,8 @@ class TestInternalClient(unittest.TestCase): self, path, metadata_prefix, acceptable_statuses) metadata = client.get_account_metadata( account, metadata_prefix, acceptable_statuses) - self.assertEquals(client.metadata, metadata) - self.assertEquals(1, client.get_metadata_called) + self.assertEqual(client.metadata, metadata) + self.assertEqual(1, client.get_metadata_called) def test_get_metadadata_with_acceptable_status(self): account, container, obj = path_parts() @@ -776,7 +776,7 @@ class TestInternalClient(unittest.TestCase): self, path, metadata, metadata_prefix, acceptable_statuses) client.set_account_metadata( account, metadata, metadata_prefix, acceptable_statuses) - self.assertEquals(1, client.set_metadata_called) + self.assertEqual(1, client.set_metadata_called) def test_container_exists(self): class Response(object): @@ -794,23 +794,23 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals('HEAD', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals({}, headers) - self.test.assertEquals((2, 404), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('HEAD', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual({}, headers) + self.test.assertEqual((2, 404), acceptable_statuses) + self.test.assertEqual(None, body_file) return self.resp account, container, obj = path_parts() path = make_path(account, container) client = InternalClient(self, path, Response(200)) - self.assertEquals(True, client.container_exists(account, container)) - self.assertEquals(1, client.make_request_called) + self.assertEqual(True, client.container_exists(account, container)) + self.assertEqual(1, client.make_request_called) client = InternalClient(self, path, Response(404)) - self.assertEquals(False, client.container_exists(account, container)) - self.assertEquals(1, client.make_request_called) + self.assertEqual(False, client.container_exists(account, container)) + self.assertEqual(1, client.make_request_called) def test_create_container(self): class InternalClient(internal_client.InternalClient): @@ -824,18 +824,18 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals('PUT', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals(self.headers, headers) - self.test.assertEquals((2,), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('PUT', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual(self.headers, headers) + self.test.assertEqual((2,), acceptable_statuses) + self.test.assertEqual(None, body_file) account, container, obj = path_parts() path = make_path(account, container) headers = 'some_headers' client = InternalClient(self, path, headers) client.create_container(account, container, headers) - self.assertEquals(1, client.make_request_called) + self.assertEqual(1, client.make_request_called) def test_delete_container(self): class InternalClient(internal_client.InternalClient): @@ -848,17 +848,17 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals('DELETE', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals({}, headers) - self.test.assertEquals((2, 404), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('DELETE', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual({}, headers) + self.test.assertEqual((2, 404), acceptable_statuses) + self.test.assertEqual(None, body_file) account, container, obj = path_parts() path = make_path(account, container) client = InternalClient(self, path) client.delete_container(account, container) - self.assertEquals(1, client.make_request_called) + self.assertEqual(1, client.make_request_called) def test_get_container_metadata(self): account, container, obj = path_parts() @@ -869,8 +869,8 @@ class TestInternalClient(unittest.TestCase): self, path, metadata_prefix, acceptable_statuses) metadata = client.get_container_metadata( account, container, metadata_prefix, acceptable_statuses) - self.assertEquals(client.metadata, metadata) - self.assertEquals(1, client.get_metadata_called) + self.assertEqual(client.metadata, metadata) + self.assertEqual(1, client.get_metadata_called) def test_iter_objects(self): account, container, obj = path_parts() @@ -885,7 +885,7 @@ class TestInternalClient(unittest.TestCase): for obj in client.iter_objects( account, container, marker, end_marker, acceptable_statuses): ret_items.append(obj) - self.assertEquals(items, ret_items) + self.assertEqual(items, ret_items) def test_set_container_metadata(self): account, container, obj = path_parts() @@ -897,7 +897,7 @@ class TestInternalClient(unittest.TestCase): self, path, metadata, metadata_prefix, acceptable_statuses) client.set_container_metadata( account, container, metadata, metadata_prefix, acceptable_statuses) - self.assertEquals(1, client.set_metadata_called) + self.assertEqual(1, client.set_metadata_called) def test_delete_object(self): class InternalClient(internal_client.InternalClient): @@ -910,18 +910,18 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals('DELETE', method) - self.test.assertEquals(self.path, path) - self.test.assertEquals({}, headers) - self.test.assertEquals((2, 404), acceptable_statuses) - self.test.assertEquals(None, body_file) + self.test.assertEqual('DELETE', method) + self.test.assertEqual(self.path, path) + self.test.assertEqual({}, headers) + self.test.assertEqual((2, 404), acceptable_statuses) + self.test.assertEqual(None, body_file) account, container, obj = path_parts() path = make_path(account, container, obj) client = InternalClient(self, path) client.delete_object(account, container, obj) - self.assertEquals(1, client.make_request_called) + self.assertEqual(1, client.make_request_called) def test_get_object_metadata(self): account, container, obj = path_parts() @@ -933,8 +933,8 @@ class TestInternalClient(unittest.TestCase): metadata = client.get_object_metadata( account, container, obj, metadata_prefix, acceptable_statuses) - self.assertEquals(client.metadata, metadata) - self.assertEquals(1, client.get_metadata_called) + self.assertEqual(client.metadata, metadata) + self.assertEqual(1, client.get_metadata_called) def test_get_metadata_extra_headers(self): class InternalClient(internal_client.InternalClient): @@ -994,7 +994,7 @@ class TestInternalClient(unittest.TestCase): ret_lines = [] for line in client.iter_object_lines('account', 'container', 'object'): ret_lines.append(line) - self.assertEquals(lines, ret_lines) + self.assertEqual(lines, ret_lines) def test_iter_object_lines_compressed_object(self): class InternalClient(internal_client.InternalClient): @@ -1015,7 +1015,7 @@ class TestInternalClient(unittest.TestCase): for line in client.iter_object_lines( 'account', 'container', 'object.gz'): ret_lines.append(line) - self.assertEquals(lines, ret_lines) + self.assertEqual(lines, ret_lines) def test_iter_object_lines_404(self): class InternalClient(internal_client.InternalClient): @@ -1034,7 +1034,7 @@ class TestInternalClient(unittest.TestCase): 'some_account', 'some_container', 'some_object', acceptable_statuses=(2, 404)): lines.append(line) - self.assertEquals([], lines) + self.assertEqual([], lines) def test_set_object_metadata(self): account, container, obj = path_parts() @@ -1047,7 +1047,7 @@ class TestInternalClient(unittest.TestCase): client.set_object_metadata( account, container, obj, metadata, metadata_prefix, acceptable_statuses) - self.assertEquals(1, client.set_metadata_called) + self.assertEqual(1, client.set_metadata_called) def test_upload_object(self): class InternalClient(internal_client.InternalClient): @@ -1062,11 +1062,11 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals(self.path, path) + self.test.assertEqual(self.path, path) exp_headers = dict(self.headers) exp_headers['Transfer-Encoding'] = 'chunked' - self.test.assertEquals(exp_headers, headers) - self.test.assertEquals(self.fobj, fobj) + self.test.assertEqual(exp_headers, headers) + self.test.assertEqual(self.fobj, fobj) fobj = 'some_fobj' account, container, obj = path_parts() @@ -1075,7 +1075,7 @@ class TestInternalClient(unittest.TestCase): client = InternalClient(self, path, headers, fobj) client.upload_object(fobj, account, container, obj, headers) - self.assertEquals(1, client.make_request_called) + self.assertEqual(1, client.make_request_called) def test_upload_object_not_chunked(self): class InternalClient(internal_client.InternalClient): @@ -1090,10 +1090,10 @@ class TestInternalClient(unittest.TestCase): self, method, path, headers, acceptable_statuses, body_file=None): self.make_request_called += 1 - self.test.assertEquals(self.path, path) + self.test.assertEqual(self.path, path) exp_headers = dict(self.headers) - self.test.assertEquals(exp_headers, headers) - self.test.assertEquals(self.fobj, fobj) + self.test.assertEqual(exp_headers, headers) + self.test.assertEqual(self.fobj, fobj) fobj = 'some_fobj' account, container, obj = path_parts() @@ -1102,7 +1102,7 @@ class TestInternalClient(unittest.TestCase): client = InternalClient(self, path, headers, fobj) client.upload_object(fobj, account, container, obj, headers) - self.assertEquals(1, client.make_request_called) + self.assertEqual(1, client.make_request_called) class TestGetAuth(unittest.TestCase): diff --git a/test/unit/common/test_manager.py b/test/unit/common/test_manager.py index ebdab67d26..80323280cb 100644 --- a/test/unit/common/test_manager.py +++ b/test/unit/common/test_manager.py @@ -71,10 +71,10 @@ class TestManagerModule(unittest.TestCase): def test_servers(self): main_plus_rest = set(manager.MAIN_SERVERS + manager.REST_SERVERS) - self.assertEquals(set(manager.ALL_SERVERS), main_plus_rest) + self.assertEqual(set(manager.ALL_SERVERS), main_plus_rest) # make sure there's no server listed in both - self.assertEquals(len(main_plus_rest), len(manager.MAIN_SERVERS) + - len(manager.REST_SERVERS)) + self.assertEqual(len(main_plus_rest), len(manager.MAIN_SERVERS) + + len(manager.REST_SERVERS)) def test_setup_env(self): class MockResource(object): @@ -108,7 +108,7 @@ class TestManagerModule(unittest.TestCase): (resource.RLIMIT_NPROC, (manager.MAX_PROCS, manager.MAX_PROCS)), ] - self.assertEquals(manager.resource.called_with_args, expected) + self.assertEqual(manager.resource.called_with_args, expected) self.assertTrue( manager.os.environ['PYTHON_EGG_CACHE'].startswith('/tmp')) @@ -116,14 +116,14 @@ class TestManagerModule(unittest.TestCase): manager.resource = MockResource(error=ValueError()) manager.os.environ = {} manager.setup_env() - self.assertEquals(manager.resource.called_with_args, []) + self.assertEqual(manager.resource.called_with_args, []) self.assertTrue( manager.os.environ['PYTHON_EGG_CACHE'].startswith('/tmp')) manager.resource = MockResource(error=OSError()) manager.os.environ = {} self.assertRaises(OSError, manager.setup_env) - self.assertEquals(manager.os.environ.get('PYTHON_EGG_CACHE'), None) + self.assertEqual(manager.os.environ.get('PYTHON_EGG_CACHE'), None) finally: manager.resource = _orig_resource os.environ = _orig_environ @@ -135,11 +135,11 @@ class TestManagerModule(unittest.TestCase): """ return arg1 - self.assertEquals(myfunc.__doc__.strip(), 'test doc') - self.assertEquals(myfunc(1), 1) - self.assertEquals(myfunc(0), 0) - self.assertEquals(myfunc(True), 1) - self.assertEquals(myfunc(False), 0) + self.assertEqual(myfunc.__doc__.strip(), 'test doc') + self.assertEqual(myfunc(1), 1) + self.assertEqual(myfunc(0), 0) + self.assertEqual(myfunc(True), 1) + self.assertEqual(myfunc(False), 0) self.assertTrue(hasattr(myfunc, 'publicly_accessible')) self.assertTrue(myfunc.publicly_accessible) @@ -211,17 +211,17 @@ class TestManagerModule(unittest.TestCase): # basic test, server dies gen = manager.watch_server_pids(server_pids) expected = [(server, 1)] - self.assertEquals([x for x in gen], expected) + self.assertEqual([x for x in gen], expected) # start long running server and short interval server = MockServer([1], zombie=15) server_pids = { server: [1], } gen = manager.watch_server_pids(server_pids) - self.assertEquals([x for x in gen], []) + self.assertEqual([x for x in gen], []) # wait a little longer gen = manager.watch_server_pids(server_pids, interval=15) - self.assertEquals([x for x in gen], [(server, 1)]) + self.assertEqual([x for x in gen], [(server, 1)]) # zombie process server = MockServer([1], zombie=200) server_pids = { @@ -250,7 +250,7 @@ class TestManagerModule(unittest.TestCase): (server2, 2), (server2, 20), ] - self.assertEquals([x for x in gen], expected) + self.assertEqual([x for x in gen], expected) finally: manager.os = _orig_os @@ -291,19 +291,19 @@ class TestServer(unittest.TestCase): def test_create_server(self): server = manager.Server('proxy') - self.assertEquals(server.server, 'proxy-server') - self.assertEquals(server.type, 'proxy') - self.assertEquals(server.cmd, 'swift-proxy-server') + self.assertEqual(server.server, 'proxy-server') + self.assertEqual(server.type, 'proxy') + self.assertEqual(server.cmd, 'swift-proxy-server') server = manager.Server('object-replicator') - self.assertEquals(server.server, 'object-replicator') - self.assertEquals(server.type, 'object') - self.assertEquals(server.cmd, 'swift-object-replicator') + self.assertEqual(server.server, 'object-replicator') + self.assertEqual(server.type, 'object') + self.assertEqual(server.cmd, 'swift-object-replicator') def test_server_to_string(self): server = manager.Server('Proxy') - self.assertEquals(str(server), 'proxy-server') + self.assertEqual(str(server), 'proxy-server') server = manager.Server('object-replicator') - self.assertEquals(str(server), 'object-replicator') + self.assertEqual(str(server), 'object-replicator') def test_server_repr(self): server = manager.Server('proxy') @@ -313,7 +313,7 @@ class TestServer(unittest.TestCase): def test_server_equality(self): server1 = manager.Server('Proxy') server2 = manager.Server('proxy-server') - self.assertEquals(server1, server2) + self.assertEqual(server1, server2) # it is NOT a string self.assertNotEquals(server1, 'proxy-server') @@ -321,17 +321,17 @@ class TestServer(unittest.TestCase): server = manager.Server('proxy') conf_file = self.join_swift_dir('proxy-server.conf') pid_file = self.join_run_dir('proxy-server.pid') - self.assertEquals(pid_file, server.get_pid_file_name(conf_file)) + self.assertEqual(pid_file, server.get_pid_file_name(conf_file)) server = manager.Server('object-replicator') conf_file = self.join_swift_dir('object-server/1.conf') pid_file = self.join_run_dir('object-replicator/1.pid') - self.assertEquals(pid_file, server.get_pid_file_name(conf_file)) + self.assertEqual(pid_file, server.get_pid_file_name(conf_file)) server = manager.Server('container-auditor') conf_file = self.join_swift_dir( 'container-server/1/container-auditor.conf') pid_file = self.join_run_dir( 'container-auditor/1/container-auditor.pid') - self.assertEquals(pid_file, server.get_pid_file_name(conf_file)) + self.assertEqual(pid_file, server.get_pid_file_name(conf_file)) def test_get_custom_pid_file_name(self): random_run_dir = "/random/dir" @@ -339,38 +339,38 @@ class TestServer(unittest.TestCase): server = manager.Server('proxy', run_dir=random_run_dir) conf_file = self.join_swift_dir('proxy-server.conf') pid_file = get_random_run_dir('proxy-server.pid') - self.assertEquals(pid_file, server.get_pid_file_name(conf_file)) + self.assertEqual(pid_file, server.get_pid_file_name(conf_file)) server = manager.Server('object-replicator', run_dir=random_run_dir) conf_file = self.join_swift_dir('object-server/1.conf') pid_file = get_random_run_dir('object-replicator/1.pid') - self.assertEquals(pid_file, server.get_pid_file_name(conf_file)) + self.assertEqual(pid_file, server.get_pid_file_name(conf_file)) server = manager.Server('container-auditor', run_dir=random_run_dir) conf_file = self.join_swift_dir( 'container-server/1/container-auditor.conf') pid_file = get_random_run_dir( 'container-auditor/1/container-auditor.pid') - self.assertEquals(pid_file, server.get_pid_file_name(conf_file)) + self.assertEqual(pid_file, server.get_pid_file_name(conf_file)) def test_get_conf_file_name(self): server = manager.Server('proxy') conf_file = self.join_swift_dir('proxy-server.conf') pid_file = self.join_run_dir('proxy-server.pid') - self.assertEquals(conf_file, server.get_conf_file_name(pid_file)) + self.assertEqual(conf_file, server.get_conf_file_name(pid_file)) server = manager.Server('object-replicator') conf_file = self.join_swift_dir('object-server/1.conf') pid_file = self.join_run_dir('object-replicator/1.pid') - self.assertEquals(conf_file, server.get_conf_file_name(pid_file)) + self.assertEqual(conf_file, server.get_conf_file_name(pid_file)) server = manager.Server('container-auditor') conf_file = self.join_swift_dir( 'container-server/1/container-auditor.conf') pid_file = self.join_run_dir( 'container-auditor/1/container-auditor.pid') - self.assertEquals(conf_file, server.get_conf_file_name(pid_file)) + self.assertEqual(conf_file, server.get_conf_file_name(pid_file)) server_name = manager.STANDALONE_SERVERS[0] server = manager.Server(server_name) conf_file = self.join_swift_dir(server_name + '.conf') pid_file = self.join_run_dir(server_name + '.pid') - self.assertEquals(conf_file, server.get_conf_file_name(pid_file)) + self.assertEqual(conf_file, server.get_conf_file_name(pid_file)) def test_conf_files(self): # test get single conf file @@ -383,10 +383,10 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('proxy') conf_files = server.conf_files() - self.assertEquals(len(conf_files), 1) + self.assertEqual(len(conf_files), 1) conf_file = conf_files[0] proxy_conf = self.join_swift_dir('proxy-server.conf') - self.assertEquals(conf_file, proxy_conf) + self.assertEqual(conf_file, proxy_conf) # test multi server conf files & grouping of server-type config conf_files = ( @@ -401,7 +401,7 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('object-replicator') conf_files = server.conf_files() - self.assertEquals(len(conf_files), 4) + self.assertEqual(len(conf_files), 4) c1 = self.join_swift_dir('object-server1.conf') c2 = self.join_swift_dir('object-server/2.conf') c3 = self.join_swift_dir('object-server/object3.conf') @@ -410,7 +410,7 @@ class TestServer(unittest.TestCase): self.assertTrue(c in conf_files) # test configs returned sorted sorted_confs = sorted([c1, c2, c3, c4]) - self.assertEquals(conf_files, sorted_confs) + self.assertEqual(conf_files, sorted_confs) # test get single numbered conf conf_files = ( @@ -423,10 +423,10 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('account') conf_files = server.conf_files(number=2) - self.assertEquals(len(conf_files), 1) + self.assertEqual(len(conf_files), 1) conf_file = conf_files[0] - self.assertEquals(conf_file, - self.join_swift_dir('account-server/2.conf')) + self.assertEqual(conf_file, + self.join_swift_dir('account-server/2.conf')) # test missing config number conf_files = server.conf_files(number=5) self.assertFalse(conf_files) @@ -442,10 +442,10 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('account.2') conf_files = server.conf_files() - self.assertEquals(len(conf_files), 1) + self.assertEqual(len(conf_files), 1) conf_file = conf_files[0] - self.assertEquals(conf_file, - self.join_swift_dir('account-server/2.conf')) + self.assertEqual(conf_file, + self.join_swift_dir('account-server/2.conf')) # test verbose & quiet conf_files = ( @@ -466,11 +466,11 @@ class TestServer(unittest.TestCase): in pop_stream(f).lower()) # check quiet will silence warning conf_files = server.conf_files(verbose=True, quiet=True) - self.assertEquals(pop_stream(f), '') + self.assertEqual(pop_stream(f), '') # check found config no warning server = manager.Server('container-auditor') conf_files = server.conf_files() - self.assertEquals(pop_stream(f), '') + self.assertEqual(pop_stream(f), '') # check missing config number warn "unable to locate" conf_files = server.conf_files(number=2) self.assertTrue( @@ -490,10 +490,10 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server(server_name) conf_files = server.conf_files() - self.assertEquals(len(conf_files), 1) + self.assertEqual(len(conf_files), 1) conf_file = conf_files[0] conf = self.join_swift_dir(server_name + '.conf') - self.assertEquals(conf_file, conf) + self.assertEqual(conf_file, conf) def test_proxy_conf_dir(self): conf_files = ( @@ -504,10 +504,10 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('proxy') conf_dirs = server.conf_files() - self.assertEquals(len(conf_dirs), 1) + self.assertEqual(len(conf_dirs), 1) conf_dir = conf_dirs[0] proxy_conf_dir = self.join_swift_dir('proxy-server.conf.d') - self.assertEquals(proxy_conf_dir, conf_dir) + self.assertEqual(proxy_conf_dir, conf_dir) def test_named_conf_dir(self): conf_files = ( @@ -521,15 +521,15 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('object.replication') conf_dirs = server.conf_files() - self.assertEquals(len(conf_dirs), 1) + self.assertEqual(len(conf_dirs), 1) conf_dir = conf_dirs[0] replication_server_conf_dir = self.join_swift_dir( 'object-server/object-replication.conf.d') - self.assertEquals(replication_server_conf_dir, conf_dir) + self.assertEqual(replication_server_conf_dir, conf_dir) # and again with no named filter server = manager.Server('object') conf_dirs = server.conf_files() - self.assertEquals(len(conf_dirs), 2) + self.assertEqual(len(conf_dirs), 2) for named_conf in ('server', 'replication'): conf_dir = self.join_swift_dir( 'object-server/object-%s.conf.d' % named_conf) @@ -551,7 +551,7 @@ class TestServer(unittest.TestCase): manager.SWIFT_DIR = t server = manager.Server('object-replicator') conf_dirs = server.conf_files() - self.assertEquals(len(conf_dirs), 4) + self.assertEqual(len(conf_dirs), 4) c1 = self.join_swift_dir('object-server/1.conf.d') c2 = self.join_swift_dir('object-server/2.conf.d') c3 = self.join_swift_dir('object-server/3.conf.d') @@ -560,7 +560,7 @@ class TestServer(unittest.TestCase): self.assertTrue(c in conf_dirs) # test configs returned sorted sorted_confs = sorted([c1, c2, c3, c4]) - self.assertEquals(conf_dirs, sorted_confs) + self.assertEqual(conf_dirs, sorted_confs) def test_named_conf_dir_pid_files(self): conf_files = ( @@ -571,15 +571,15 @@ class TestServer(unittest.TestCase): manager.RUN_DIR = t server = manager.Server('object.replication', run_dir=t) pid_files = server.pid_files() - self.assertEquals(len(pid_files), 1) + self.assertEqual(len(pid_files), 1) pid_file = pid_files[0] replication_server_pid = self.join_run_dir( 'object-server/object-replication.pid.d') - self.assertEquals(replication_server_pid, pid_file) + self.assertEqual(replication_server_pid, pid_file) # and again with no named filter server = manager.Server('object', run_dir=t) pid_files = server.pid_files() - self.assertEquals(len(pid_files), 2) + self.assertEqual(len(pid_files), 2) for named_pid in ('server', 'replication'): pid_file = self.join_run_dir( 'object-server/object-%s.pid.d' % named_pid) @@ -603,8 +603,8 @@ class TestServer(unittest.TestCase): # test get one file iter = server.iter_pid_files() pid_file, pid = next(iter) - self.assertEquals(pid_file, self.join_run_dir('proxy-server.pid')) - self.assertEquals(pid, 1) + self.assertEqual(pid_file, self.join_run_dir('proxy-server.pid')) + self.assertEqual(pid, 1) # ... and only one file self.assertRaises(StopIteration, iter.next) # test invalid value in pid file @@ -623,7 +623,7 @@ class TestServer(unittest.TestCase): pid_map = {} for pid_file, pid in server.iter_pid_files(): pid_map[pid] = pid_file - self.assertEquals(pid_map, real_map) + self.assertEqual(pid_map, real_map) # test get pid_files by number conf_files = ( @@ -654,14 +654,14 @@ class TestServer(unittest.TestCase): pid_map = {} for pid_file, pid in server.iter_pid_files(): pid_map[pid] = pid_file - self.assertEquals(pid_map, real_map) + self.assertEqual(pid_map, real_map) # test get pid with matching conf pids = list(server.iter_pid_files(number=2)) - self.assertEquals(len(pids), 1) + self.assertEqual(len(pids), 1) pid_file, pid = pids[0] - self.assertEquals(pid, 2) + self.assertEqual(pid, 2) pid_two = self.join_run_dir('object-server/2.pid') - self.assertEquals(pid_file, pid_two) + self.assertEqual(pid_file, pid_two) # try to iter on a pid number with a matching conf but no pid pids = list(server.iter_pid_files(number=3)) self.assertFalse(pids) @@ -691,11 +691,11 @@ class TestServer(unittest.TestCase): server = manager.Server('object.2', run_dir=t) # test get pid with matching conf pids = list(server.iter_pid_files()) - self.assertEquals(len(pids), 1) + self.assertEqual(len(pids), 1) pid_file, pid = pids[0] - self.assertEquals(pid, 2) + self.assertEqual(pid, 2) pid_two = self.join_run_dir('object-server/2.pid') - self.assertEquals(pid_file, pid_two) + self.assertEqual(pid_file, pid_two) def test_signal_pids(self): temp_files = ( @@ -714,9 +714,9 @@ class TestServer(unittest.TestCase): manager.os = MockOs([1, 2]) server = manager.Server('proxy', run_dir=manager.RUN_DIR) pids = server.signal_pids(DUMMY_SIG) - self.assertEquals(len(pids), 1) + self.assertEqual(len(pids), 1) self.assertTrue(1 in pids) - self.assertEquals(manager.os.pid_sigs[1], [DUMMY_SIG]) + self.assertEqual(manager.os.pid_sigs[1], [DUMMY_SIG]) # make sure other process not signaled self.assertFalse(2 in pids) self.assertFalse(2 in manager.os.pid_sigs) @@ -732,7 +732,7 @@ class TestServer(unittest.TestCase): self.assertTrue('signal: %s' % DUMMY_SIG in output) # test no details on signal.SIG_DFL pids = server.signal_pids(signal.SIG_DFL) - self.assertEquals(pop_stream(f), '') + self.assertEqual(pop_stream(f), '') # reset mock os so only the second server is running manager.os = MockOs([2]) # test pid not running @@ -812,7 +812,7 @@ class TestServer(unittest.TestCase): # mock os, only pid '1' is running manager.os = MockOs([1, 3]) running_pids = server.get_running_pids() - self.assertEquals(len(running_pids), 1) + self.assertEqual(len(running_pids), 1) self.assertTrue(1 in running_pids) self.assertTrue(2 not in running_pids) self.assertTrue(3 not in running_pids) @@ -832,7 +832,7 @@ class TestServer(unittest.TestCase): pid_one = self.join_run_dir('test-server1.pid') self.assertFalse(os.path.exists(pid_one)) all_pids = os.listdir(manager.RUN_DIR) - self.assertEquals(len(all_pids), 0) + self.assertEqual(len(all_pids), 0) # test only get pids for right server pid_files = ( @@ -849,7 +849,7 @@ class TestServer(unittest.TestCase): server = manager.Server('thing-doer', run_dir=t) running_pids = server.get_running_pids() # only thing-doer.pid, 1 - self.assertEquals(len(running_pids), 1) + self.assertEqual(len(running_pids), 1) self.assertTrue(1 in running_pids) # no other pids returned for n in (2, 3, 4): @@ -867,7 +867,7 @@ class TestServer(unittest.TestCase): self.assertFalse(running_pids) # and now all OTHER pid files are cleaned out all_pids = os.listdir(t) - self.assertEquals(len(all_pids), 1) + self.assertEqual(len(all_pids), 1) self.assertTrue(os.path.exists(os.path.join(t, 'thing-doer.pid'))) def test_kill_running_pids(self): @@ -893,18 +893,18 @@ class TestServer(unittest.TestCase): server = manager.Server('object', run_dir=t) # test kill one pid pids = server.kill_running_pids() - self.assertEquals(len(pids), 1) + self.assertEqual(len(pids), 1) self.assertTrue(1 in pids) - self.assertEquals(manager.os.pid_sigs[1], [signal.SIGTERM]) + self.assertEqual(manager.os.pid_sigs[1], [signal.SIGTERM]) # reset os mock manager.os = MockOs([1]) # test shutdown self.assertTrue('object-server' in manager.GRACEFUL_SHUTDOWN_SERVERS) pids = server.kill_running_pids(graceful=True) - self.assertEquals(len(pids), 1) + self.assertEqual(len(pids), 1) self.assertTrue(1 in pids) - self.assertEquals(manager.os.pid_sigs[1], [signal.SIGHUP]) + self.assertEqual(manager.os.pid_sigs[1], [signal.SIGHUP]) # start up other servers manager.os = MockOs([11, 12]) # test multi server kill & ignore graceful on unsupported server @@ -912,11 +912,11 @@ class TestServer(unittest.TestCase): manager.GRACEFUL_SHUTDOWN_SERVERS) server = manager.Server('object-replicator', run_dir=t) pids = server.kill_running_pids(graceful=True) - self.assertEquals(len(pids), 2) + self.assertEqual(len(pids), 2) for pid in (11, 12): self.assertTrue(pid in pids) - self.assertEquals(manager.os.pid_sigs[pid], - [signal.SIGTERM]) + self.assertEqual(manager.os.pid_sigs[pid], + [signal.SIGTERM]) # and the other pid is of course not signaled self.assertTrue(1 not in manager.os.pid_sigs) @@ -958,17 +958,17 @@ class TestServer(unittest.TestCase): files, contents = zip(*proc_files) with temptree(files, contents) as t: manager.PROC_DIR = t - self.assertEquals(server.status(), 0) + self.assertEqual(server.status(), 0) output = pop_stream(f).strip().splitlines() - self.assertEquals(len(output), 4) + self.assertEqual(len(output), 4) for line in output: self.assertTrue('test-server running' in line) # test get single server by number with temptree([], []) as t: manager.PROC_DIR = t - self.assertEquals(server.status(number=4), 0) + self.assertEqual(server.status(number=4), 0) output = pop_stream(f).strip().splitlines() - self.assertEquals(len(output), 1) + self.assertEqual(len(output), 1) line = output[0] self.assertTrue('test-server running' in line) conf_four = self.join_swift_dir(conf_files[3]) @@ -983,9 +983,9 @@ class TestServer(unittest.TestCase): files, contents = zip(*proc_files) with temptree(files, contents) as t: manager.PROC_DIR = t - self.assertEquals(server.status(), 0) + self.assertEqual(server.status(), 0) output = pop_stream(f).strip().splitlines() - self.assertEquals(len(output), 3) + self.assertEqual(len(output), 3) for line in output: self.assertTrue('test-server running' in line) # test single server not running @@ -997,9 +997,9 @@ class TestServer(unittest.TestCase): files, contents = zip(*proc_files) with temptree(files, contents) as t: manager.PROC_DIR = t - self.assertEquals(server.status(number=3), 1) + self.assertEqual(server.status(number=3), 1) output = pop_stream(f).strip().splitlines() - self.assertEquals(len(output), 1) + self.assertEqual(len(output), 1) line = output[0] self.assertTrue('not running' in line) conf_three = self.join_swift_dir(conf_files[2]) @@ -1008,7 +1008,7 @@ class TestServer(unittest.TestCase): manager.os = MockOs([]) with temptree([], []) as t: manager.PROC_DIR = t - self.assertEquals(server.status(), 1) + self.assertEqual(server.status(), 1) output = pop_stream(f).lower() self.assertTrue('no test-server running' in output) # test use provided pids @@ -1023,10 +1023,10 @@ class TestServer(unittest.TestCase): called.append(True) server.get_running_pids = mock status = server.status(pids=pids) - self.assertEquals(status, 0) + self.assertEqual(status, 0) self.assertFalse(called) output = pop_stream(f).strip().splitlines() - self.assertEquals(len(output), 2) + self.assertEqual(len(output), 2) for line in output: self.assertTrue('test-server running' in line) finally: @@ -1080,19 +1080,19 @@ class TestServer(unittest.TestCase): pid_file = self.join_run_dir('test-server.pid') self.assertTrue(os.path.exists(pid_file)) pid_on_disk = int(open(pid_file).read().strip()) - self.assertEquals(pid_on_disk, 1) + self.assertEqual(pid_on_disk, 1) # assert procs args self.assertTrue(server.procs) - self.assertEquals(len(server.procs), 1) + self.assertEqual(len(server.procs), 1) proc = server.procs[0] expected_args = [ 'swift-test-server', conf_file, ] - self.assertEquals(proc.args, expected_args) + self.assertEqual(proc.args, expected_args) # assert stdout is piped - self.assertEquals(proc.stdout, MockProcess.PIPE) - self.assertEquals(proc.stderr, proc.stdout) + self.assertEqual(proc.stdout, MockProcess.PIPE) + self.assertEqual(proc.stderr, proc.stdout) # test multi server process calls spawn multiple times manager.subprocess = MockProcess([11, 12, 13, 14]) conf1 = self.join_swift_dir('test-server/1.conf') @@ -1103,55 +1103,55 @@ class TestServer(unittest.TestCase): # test server run once server.spawn(conf1, once=True) self.assertTrue(server.procs) - self.assertEquals(len(server.procs), 1) + self.assertEqual(len(server.procs), 1) proc = server.procs[0] expected_args = ['swift-test-server', conf1, 'once'] # assert stdout is piped - self.assertEquals(proc.stdout, MockProcess.PIPE) - self.assertEquals(proc.stderr, proc.stdout) + self.assertEqual(proc.stdout, MockProcess.PIPE) + self.assertEqual(proc.stderr, proc.stdout) # test server not daemon server.spawn(conf2, daemon=False) self.assertTrue(server.procs) - self.assertEquals(len(server.procs), 2) + self.assertEqual(len(server.procs), 2) proc = server.procs[1] expected_args = ['swift-test-server', conf2, 'verbose'] - self.assertEquals(proc.args, expected_args) + self.assertEqual(proc.args, expected_args) # assert stdout is not changed - self.assertEquals(proc.stdout, None) - self.assertEquals(proc.stderr, None) + self.assertEqual(proc.stdout, None) + self.assertEqual(proc.stderr, None) # test server wait server.spawn(conf3, wait=False) self.assertTrue(server.procs) - self.assertEquals(len(server.procs), 3) + self.assertEqual(len(server.procs), 3) proc = server.procs[2] # assert stdout is /dev/null self.assertTrue(isinstance(proc.stdout, file)) - self.assertEquals(proc.stdout.name, os.devnull) - self.assertEquals(proc.stdout.mode, 'w+b') - self.assertEquals(proc.stderr, proc.stdout) + self.assertEqual(proc.stdout.name, os.devnull) + self.assertEqual(proc.stdout.mode, 'w+b') + self.assertEqual(proc.stderr, proc.stdout) # test not daemon over-rides wait server.spawn(conf4, wait=False, daemon=False, once=True) self.assertTrue(server.procs) - self.assertEquals(len(server.procs), 4) + self.assertEqual(len(server.procs), 4) proc = server.procs[3] expected_args = ['swift-test-server', conf4, 'once', 'verbose'] - self.assertEquals(proc.args, expected_args) + self.assertEqual(proc.args, expected_args) # daemon behavior should trump wait, once shouldn't matter - self.assertEquals(proc.stdout, None) - self.assertEquals(proc.stderr, None) + self.assertEqual(proc.stdout, None) + self.assertEqual(proc.stderr, None) # assert pids for i, proc in enumerate(server.procs): pid_file = self.join_run_dir('test-server/%d.pid' % (i + 1)) pid_on_disk = int(open(pid_file).read().strip()) - self.assertEquals(pid_on_disk, proc.pid) + self.assertEqual(pid_on_disk, proc.pid) finally: manager.subprocess = old_subprocess def test_wait(self): server = manager.Server('test') - self.assertEquals(server.wait(), 0) + self.assertEqual(server.wait(), 0) class MockProcess(Thread): def __init__(self, delay=0.1, fail_to_start=False): @@ -1228,7 +1228,7 @@ class TestServer(unittest.TestCase): with MockProcess() as proc: server.procs = [proc] status = server.wait() - self.assertEquals(status, 0) + self.assertEqual(status, 0) # wait should return before process exits self.assertTrue(proc.isAlive()) self.assertFalse(proc.finished) @@ -1246,7 +1246,7 @@ class TestServer(unittest.TestCase): with MockProcess(fail_to_start=True) as proc: server.procs = [proc] status = server.wait() - self.assertEquals(status, 1) + self.assertEqual(status, 1) self.assertTrue('failed' in pop_stream(f)) # test multiple procs procs = [MockProcess(delay=.5) for i in range(3)] @@ -1254,7 +1254,7 @@ class TestServer(unittest.TestCase): proc.start() server.procs = procs status = server.wait() - self.assertEquals(status, 0) + self.assertEqual(status, 0) for proc in procs: self.assertTrue(proc.isAlive()) for proc in procs: @@ -1280,9 +1280,9 @@ class TestServer(unittest.TestCase): server = manager.Server('test') server.procs = [MockProcess()] - self.assertEquals(server.interact(), 0) + self.assertEqual(server.interact(), 0) server.procs = [MockProcess(fail=True)] - self.assertEquals(server.interact(), 1) + self.assertEqual(server.interact(), 1) procs = [] for fail in (False, True, True): procs.append(MockProcess(fail=fail)) @@ -1371,14 +1371,14 @@ class TestServer(unittest.TestCase): expected = { 1: conf_file, } - self.assertEquals(server.launch(once=True), - expected) - self.assertEquals(mock_spawn.conf_files, - [conf_file]) + self.assertEqual(server.launch(once=True), + expected) + self.assertEqual(mock_spawn.conf_files, + [conf_file]) expected = { 'once': False, } - self.assertEquals(mock_spawn.kwargs, [expected]) + self.assertEqual(mock_spawn.kwargs, [expected]) output = pop_stream(f) self.assertTrue('Starting' in output) self.assertTrue('once' not in output) @@ -1398,16 +1398,16 @@ class TestServer(unittest.TestCase): 3: conf3, 4: conf4, } - self.assertEquals(server.launch(once=True), - expected) - self.assertEquals(mock_spawn.conf_files, [ + self.assertEqual(server.launch(once=True), + expected) + self.assertEqual(mock_spawn.conf_files, [ conf1, conf2, conf3, conf4]) expected = { 'once': True, } - self.assertEquals(len(mock_spawn.kwargs), 4) + self.assertEqual(len(mock_spawn.kwargs), 4) for kwargs in mock_spawn.kwargs: - self.assertEquals(kwargs, expected) + self.assertEqual(kwargs, expected) # test number kwarg mock_spawn = MockSpawn([4]) manager.PROC_DIR = proc_dir @@ -1415,13 +1415,13 @@ class TestServer(unittest.TestCase): expected = { 4: conf4, } - self.assertEquals(server.launch(number=4), - expected) - self.assertEquals(mock_spawn.conf_files, [conf4]) + self.assertEqual(server.launch(number=4), + expected) + self.assertEqual(mock_spawn.conf_files, [conf4]) expected = { 'number': 4 } - self.assertEquals(mock_spawn.kwargs, [expected]) + self.assertEqual(mock_spawn.kwargs, [expected]) # test cmd does not exist server = manager.Server('auth') with temptree([], []) as proc_dir: @@ -1429,7 +1429,7 @@ class TestServer(unittest.TestCase): mock_spawn = MockSpawn([OSError(errno.ENOENT, 'blah')]) server.spawn = mock_spawn - self.assertEquals(server.launch(), {}) + self.assertEqual(server.launch(), {}) self.assertTrue( 'swift-auth-server does not exist' in pop_stream(f)) @@ -1460,11 +1460,11 @@ class TestServer(unittest.TestCase): server = manager.Server('account-reaper', run_dir=t) # test kill all running pids pids = server.stop() - self.assertEquals(len(pids), 4) + self.assertEqual(len(pids), 4) for pid in (1, 2, 3, 4): self.assertTrue(pid in pids) - self.assertEquals(manager.os.pid_sigs[pid], - [signal.SIGTERM]) + self.assertEqual(manager.os.pid_sigs[pid], + [signal.SIGTERM]) conf1 = self.join_swift_dir('account-reaper/1.conf') conf2 = self.join_swift_dir('account-reaper/2.conf') conf3 = self.join_swift_dir('account-reaper/3.conf') @@ -1472,22 +1472,22 @@ class TestServer(unittest.TestCase): # reset mock os with only 2 running pids manager.os = MockOs([3, 4]) pids = server.stop() - self.assertEquals(len(pids), 2) + self.assertEqual(len(pids), 2) for pid in (3, 4): self.assertTrue(pid in pids) - self.assertEquals(manager.os.pid_sigs[pid], - [signal.SIGTERM]) + self.assertEqual(manager.os.pid_sigs[pid], + [signal.SIGTERM]) self.assertFalse(os.path.exists(conf1)) self.assertFalse(os.path.exists(conf2)) # test number kwarg manager.os = MockOs([3, 4]) pids = server.stop(number=3) - self.assertEquals(len(pids), 1) + self.assertEqual(len(pids), 1) expected = { 3: conf3, } self.assertTrue(pids, expected) - self.assertEquals(manager.os.pid_sigs[3], [signal.SIGTERM]) + self.assertEqual(manager.os.pid_sigs[3], [signal.SIGTERM]) self.assertFalse(os.path.exists(conf4)) self.assertFalse(os.path.exists(conf3)) @@ -1496,47 +1496,47 @@ class TestManager(unittest.TestCase): def test_create(self): m = manager.Manager(['test']) - self.assertEquals(len(m.servers), 1) + self.assertEqual(len(m.servers), 1) server = m.servers.pop() self.assertTrue(isinstance(server, manager.Server)) - self.assertEquals(server.server, 'test-server') + self.assertEqual(server.server, 'test-server') # test multi-server and simple dedupe servers = ['object-replicator', 'object-auditor', 'object-replicator'] m = manager.Manager(servers) - self.assertEquals(len(m.servers), 2) + self.assertEqual(len(m.servers), 2) for server in m.servers: self.assertTrue(server.server in servers) # test all m = manager.Manager(['all']) - self.assertEquals(len(m.servers), len(manager.ALL_SERVERS)) + self.assertEqual(len(m.servers), len(manager.ALL_SERVERS)) for server in m.servers: self.assertTrue(server.server in manager.ALL_SERVERS) # test main m = manager.Manager(['main']) - self.assertEquals(len(m.servers), len(manager.MAIN_SERVERS)) + self.assertEqual(len(m.servers), len(manager.MAIN_SERVERS)) for server in m.servers: self.assertTrue(server.server in manager.MAIN_SERVERS) # test rest m = manager.Manager(['rest']) - self.assertEquals(len(m.servers), len(manager.REST_SERVERS)) + self.assertEqual(len(m.servers), len(manager.REST_SERVERS)) for server in m.servers: self.assertTrue(server.server in manager.REST_SERVERS) # test main + rest == all m = manager.Manager(['main', 'rest']) - self.assertEquals(len(m.servers), len(manager.ALL_SERVERS)) + self.assertEqual(len(m.servers), len(manager.ALL_SERVERS)) for server in m.servers: self.assertTrue(server.server in manager.ALL_SERVERS) # test dedupe m = manager.Manager(['main', 'rest', 'proxy', 'object', 'container', 'account']) - self.assertEquals(len(m.servers), len(manager.ALL_SERVERS)) + self.assertEqual(len(m.servers), len(manager.ALL_SERVERS)) for server in m.servers: self.assertTrue(server.server in manager.ALL_SERVERS) # test glob m = manager.Manager(['object-*']) object_servers = [s for s in manager.ALL_SERVERS if s.startswith('object')] - self.assertEquals(len(m.servers), len(object_servers)) + self.assertEqual(len(m.servers), len(object_servers)) for s in m.servers: self.assertTrue(str(s) in object_servers) m = manager.Manager(['*-replicator']) @@ -1547,7 +1547,7 @@ class TestManager(unittest.TestCase): def test_iter(self): m = manager.Manager(['all']) - self.assertEquals(len(list(m)), len(manager.ALL_SERVERS)) + self.assertEqual(len(list(m)), len(manager.ALL_SERVERS)) for server in m: self.assertTrue(server.server in manager.ALL_SERVERS) @@ -1570,17 +1570,17 @@ class TestManager(unittest.TestCase): manager.Server = MockServer m = manager.Manager(['test']) status = m.status() - self.assertEquals(status, 0) + self.assertEqual(status, 0) m = manager.Manager(['error']) status = m.status() - self.assertEquals(status, 1) + self.assertEqual(status, 1) # test multi-server m = manager.Manager(['test', 'error']) kwargs = {'key': 'value'} status = m.status(**kwargs) - self.assertEquals(status, 1) + self.assertEqual(status, 1) for server in m.servers: - self.assertEquals(server.called_kwargs, [kwargs]) + self.assertEqual(server.called_kwargs, [kwargs]) finally: manager.Server = old_server_class @@ -1622,26 +1622,26 @@ class TestManager(unittest.TestCase): # test no errors on launch m = manager.Manager(['proxy']) status = m.start() - self.assertEquals(status, 0) + self.assertEqual(status, 0) for server in m.servers: - self.assertEquals(server.called['launch'], [{}]) + self.assertEqual(server.called['launch'], [{}]) # test error on launch m = manager.Manager(['proxy', 'error']) status = m.start() - self.assertEquals(status, 1) + self.assertEqual(status, 1) for server in m.servers: - self.assertEquals(server.called['launch'], [{}]) - self.assertEquals(server.called['wait'], [{}]) + self.assertEqual(server.called['launch'], [{}]) + self.assertEqual(server.called['wait'], [{}]) # test interact m = manager.Manager(['proxy', 'error']) kwargs = {'daemon': False} status = m.start(**kwargs) - self.assertEquals(status, 1) + self.assertEqual(status, 1) for server in m.servers: - self.assertEquals(server.called['launch'], [kwargs]) - self.assertEquals(server.called['interact'], [kwargs]) + self.assertEqual(server.called['launch'], [kwargs]) + self.assertEqual(server.called['interact'], [kwargs]) m = manager.Manager(['raise']) kwargs = {'daemon': False} status = m.start(**kwargs) @@ -1670,18 +1670,18 @@ class TestManager(unittest.TestCase): # test success init = manager.Manager(['proxy']) status = init.no_wait() - self.assertEquals(status, 0) + self.assertEqual(status, 0) for server in init.servers: - self.assertEquals(len(server.called['launch']), 1) + self.assertEqual(len(server.called['launch']), 1) called_kwargs = server.called['launch'][0] self.assertFalse(called_kwargs['wait']) self.assertFalse(server.called['wait']) # test no errocode status even on error init = manager.Manager(['error']) status = init.no_wait() - self.assertEquals(status, 0) + self.assertEqual(status, 0) for server in init.servers: - self.assertEquals(len(server.called['launch']), 1) + self.assertEqual(len(server.called['launch']), 1) called_kwargs = server.called['launch'][0] self.assertTrue('wait' in called_kwargs) self.assertFalse(called_kwargs['wait']) @@ -1689,9 +1689,9 @@ class TestManager(unittest.TestCase): # test wait with once option init = manager.Manager(['updater', 'replicator-error']) status = init.no_wait(once=True) - self.assertEquals(status, 0) + self.assertEqual(status, 0) for server in init.servers: - self.assertEquals(len(server.called['launch']), 1) + self.assertEqual(len(server.called['launch']), 1) called_kwargs = server.called['launch'][0] self.assertTrue('wait' in called_kwargs) self.assertFalse(called_kwargs['wait']) @@ -1722,18 +1722,18 @@ class TestManager(unittest.TestCase): # test success init = manager.Manager(['proxy']) stats = init.no_daemon() - self.assertEquals(stats, 0) + self.assertEqual(stats, 0) # test error init = manager.Manager(['proxy', 'object-error']) stats = init.no_daemon() - self.assertEquals(stats, 1) + self.assertEqual(stats, 1) # test once init = manager.Manager(['proxy', 'object-error']) stats = init.no_daemon() for server in init.servers: - self.assertEquals(len(server.called['launch']), 1) - self.assertEquals(len(server.called['wait']), 0) - self.assertEquals(len(server.called['interact']), 1) + self.assertEqual(len(server.called['launch']), 1) + self.assertEqual(len(server.called['wait']), 0) + self.assertEqual(len(server.called['interact']), 1) finally: manager.Server = orig_swift_server @@ -1761,17 +1761,17 @@ class TestManager(unittest.TestCase): # test no errors init = manager.Manager(['account-reaper']) status = init.once() - self.assertEquals(status, 0) + self.assertEqual(status, 0) # test error code on error init = manager.Manager(['error-reaper']) status = init.once() - self.assertEquals(status, 1) + self.assertEqual(status, 1) for server in init.servers: - self.assertEquals(len(server.called['launch']), 1) + self.assertEqual(len(server.called['launch']), 1) called_kwargs = server.called['launch'][0] - self.assertEquals(called_kwargs, {'once': True}) - self.assertEquals(len(server.called['wait']), 1) - self.assertEquals(len(server.called['interact']), 0) + self.assertEqual(called_kwargs, {'once': True}) + self.assertEqual(len(server.called['wait']), 1) + self.assertEqual(len(server.called['interact']), 0) finally: manager.Server = orig_swift_server @@ -1811,7 +1811,7 @@ class TestManager(unittest.TestCase): manager.Server = MockServerFactory(server_pids) m = manager.Manager(['test']) status = m.stop() - self.assertEquals(status, 0) + self.assertEqual(status, 0) # test not running server_pids = { 'test': [] @@ -1819,7 +1819,7 @@ class TestManager(unittest.TestCase): manager.Server = MockServerFactory(server_pids) m = manager.Manager(['test']) status = m.stop() - self.assertEquals(status, 1) + self.assertEqual(status, 1) # test kill not running server_pids = { 'test': [] @@ -1827,7 +1827,7 @@ class TestManager(unittest.TestCase): manager.Server = MockServerFactory(server_pids) m = manager.Manager(['test']) status = m.kill() - self.assertEquals(status, 0) + self.assertEqual(status, 0) # test won't die server_pids = { 'test': [None] @@ -1835,7 +1835,7 @@ class TestManager(unittest.TestCase): manager.Server = MockServerFactory(server_pids) m = manager.Manager(['test']) status = m.stop() - self.assertEquals(status, 1) + self.assertEqual(status, 1) finally: manager.Server = _orig_server @@ -1849,12 +1849,12 @@ class TestManager(unittest.TestCase): def mock_stop(*args, **kwargs): m.stop_was_called = True expected = {'graceful': True} - self.assertEquals(kwargs, expected) + self.assertEqual(kwargs, expected) return 0 m.stop = mock_stop status = m.shutdown() - self.assertEquals(status, 0) - self.assertEquals(m.stop_was_called, True) + self.assertEqual(status, 0) + self.assertEqual(m.stop_was_called, True) def test_restart(self): m = manager.Manager(['test']) @@ -1871,9 +1871,9 @@ class TestManager(unittest.TestCase): m.stop = mock_stop m.start = mock_start status = m.restart() - self.assertEquals(status, 0) - self.assertEquals(m.stop_was_called, True) - self.assertEquals(m.start_was_called, True) + self.assertEqual(status, 0) + self.assertEqual(m.stop_was_called, True) + self.assertEqual(m.start_was_called, True) def test_reload(self): class MockManager(object): @@ -1902,27 +1902,27 @@ class TestManager(unittest.TestCase): manager.GRACEFUL_SHUTDOWN_SERVERS) manager.Manager = MockManager status = m.reload() - self.assertEquals(status, 0) + self.assertEqual(status, 0) expected = { 'start': [{'graceful': True}], 'stop': [{'graceful': True}], } - self.assertEquals(MockManager.called, expected) + self.assertEqual(MockManager.called, expected) # test force graceful MockManager.reset_called() m = _orig_manager(['*-server']) - self.assertEquals(len(m.servers), 4) + self.assertEqual(len(m.servers), 4) for server in m.servers: self.assertTrue(server.server in manager.GRACEFUL_SHUTDOWN_SERVERS) manager.Manager = MockManager status = m.reload(graceful=False) - self.assertEquals(status, 0) + self.assertEqual(status, 0) expected = { 'start': [{'graceful': True}] * 4, 'stop': [{'graceful': True}] * 4, } - self.assertEquals(MockManager.called, expected) + self.assertEqual(MockManager.called, expected) finally: manager.Manager = _orig_manager @@ -1936,15 +1936,15 @@ class TestManager(unittest.TestCase): return 0 m.reload = mock_reload status = m.force_reload() - self.assertEquals(status, 0) - self.assertEquals(m.reload_was_called, True) + self.assertEqual(status, 0) + self.assertEqual(m.reload_was_called, True) def test_get_command(self): m = manager.Manager(['test']) - self.assertEquals(m.start, m.get_command('start')) - self.assertEquals(m.force_reload, m.get_command('force-reload')) - self.assertEquals(m.get_command('force-reload'), - m.get_command('force_reload')) + self.assertEqual(m.start, m.get_command('start')) + self.assertEqual(m.force_reload, m.get_command('force-reload')) + self.assertEqual(m.get_command('force-reload'), + m.get_command('force_reload')) self.assertRaises(manager.UnknownCommandError, m.get_command, 'no_command') self.assertRaises(manager.UnknownCommandError, m.get_command, @@ -1955,7 +1955,7 @@ class TestManager(unittest.TestCase): method = getattr(manager.Manager, cmd.replace('-', '_'), None) self.assertTrue(method, '%s is not a command' % cmd) self.assertTrue(getattr(method, 'publicly_accessible', False)) - self.assertEquals(method.__doc__.strip(), help) + self.assertEqual(method.__doc__.strip(), help) def test_run_command(self): m = manager.Manager(['test']) @@ -1964,14 +1964,14 @@ class TestManager(unittest.TestCase): def mock_cmd(*args, **kwargs): m.cmd_was_called = True expected = {'kw1': True, 'kw2': False} - self.assertEquals(kwargs, expected) + self.assertEqual(kwargs, expected) return 0 mock_cmd.publicly_accessible = True m.mock_cmd = mock_cmd kwargs = {'kw1': True, 'kw2': False} status = m.run_command('mock_cmd', **kwargs) - self.assertEquals(status, 0) - self.assertEquals(m.cmd_was_called, True) + self.assertEqual(status, 0) + self.assertEqual(m.cmd_was_called, True) if __name__ == '__main__': unittest.main() diff --git a/test/unit/common/test_memcached.py b/test/unit/common/test_memcached.py index 02144fdcec..dcdaebc251 100644 --- a/test/unit/common/test_memcached.py +++ b/test/unit/common/test_memcached.py @@ -191,20 +191,20 @@ class TestMemcached(unittest.TestCase): memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool( [(mock, mock)] * 2) memcache_client.set('some_key', [1, 2, 3]) - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) - self.assertEquals(mock.cache.values()[0][1], '0') + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(mock.cache.values()[0][1], '0') memcache_client.set('some_key', [4, 5, 6]) - self.assertEquals(memcache_client.get('some_key'), [4, 5, 6]) + self.assertEqual(memcache_client.get('some_key'), [4, 5, 6]) memcache_client.set('some_key', ['simple str', 'utf8 str éà']) # As per http://wiki.openstack.org/encoding, # we should expect to have unicode - self.assertEquals( + self.assertEqual( memcache_client.get('some_key'), ['simple str', u'utf8 str éà']) self.assertTrue(float(mock.cache.values()[0][1]) == 0) memcache_client.set('some_key', [1, 2, 3], timeout=10) - self.assertEquals(mock.cache.values()[0][1], '10') + self.assertEqual(mock.cache.values()[0][1], '10') memcache_client.set('some_key', [1, 2, 3], time=20) - self.assertEquals(mock.cache.values()[0][1], '20') + self.assertEqual(mock.cache.values()[0][1], '20') sixtydays = 60 * 24 * 60 * 60 esttimeout = time.time() + sixtydays @@ -220,16 +220,16 @@ class TestMemcached(unittest.TestCase): mock = MockMemcached() memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool( [(mock, mock)] * 2) - self.assertEquals(memcache_client.incr('some_key', delta=5), 5) - self.assertEquals(memcache_client.get('some_key'), '5') - self.assertEquals(memcache_client.incr('some_key', delta=5), 10) - self.assertEquals(memcache_client.get('some_key'), '10') - self.assertEquals(memcache_client.incr('some_key', delta=1), 11) - self.assertEquals(memcache_client.get('some_key'), '11') - self.assertEquals(memcache_client.incr('some_key', delta=-5), 6) - self.assertEquals(memcache_client.get('some_key'), '6') - self.assertEquals(memcache_client.incr('some_key', delta=-15), 0) - self.assertEquals(memcache_client.get('some_key'), '0') + self.assertEqual(memcache_client.incr('some_key', delta=5), 5) + self.assertEqual(memcache_client.get('some_key'), '5') + self.assertEqual(memcache_client.incr('some_key', delta=5), 10) + self.assertEqual(memcache_client.get('some_key'), '10') + self.assertEqual(memcache_client.incr('some_key', delta=1), 11) + self.assertEqual(memcache_client.get('some_key'), '11') + self.assertEqual(memcache_client.incr('some_key', delta=-5), 6) + self.assertEqual(memcache_client.get('some_key'), '6') + self.assertEqual(memcache_client.incr('some_key', delta=-15), 0) + self.assertEqual(memcache_client.get('some_key'), '0') mock.read_return_none = True self.assertRaises(memcached.MemcacheConnectionError, memcache_client.incr, 'some_key', delta=-15) @@ -241,38 +241,38 @@ class TestMemcached(unittest.TestCase): memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool( [(mock, mock)] * 2) memcache_client.incr('some_key', delta=5, time=55) - self.assertEquals(memcache_client.get('some_key'), '5') - self.assertEquals(mock.cache.values()[0][1], '55') + self.assertEqual(memcache_client.get('some_key'), '5') + self.assertEqual(mock.cache.values()[0][1], '55') memcache_client.delete('some_key') - self.assertEquals(memcache_client.get('some_key'), None) + self.assertEqual(memcache_client.get('some_key'), None) fiftydays = 50 * 24 * 60 * 60 esttimeout = time.time() + fiftydays memcache_client.incr('some_key', delta=5, time=fiftydays) - self.assertEquals(memcache_client.get('some_key'), '5') + self.assertEqual(memcache_client.get('some_key'), '5') self.assertTrue( -1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1) memcache_client.delete('some_key') - self.assertEquals(memcache_client.get('some_key'), None) + self.assertEqual(memcache_client.get('some_key'), None) memcache_client.incr('some_key', delta=5) - self.assertEquals(memcache_client.get('some_key'), '5') - self.assertEquals(mock.cache.values()[0][1], '0') + self.assertEqual(memcache_client.get('some_key'), '5') + self.assertEqual(mock.cache.values()[0][1], '0') memcache_client.incr('some_key', delta=5, time=55) - self.assertEquals(memcache_client.get('some_key'), '10') - self.assertEquals(mock.cache.values()[0][1], '0') + self.assertEqual(memcache_client.get('some_key'), '10') + self.assertEqual(mock.cache.values()[0][1], '0') def test_decr(self): memcache_client = memcached.MemcacheRing(['1.2.3.4:11211']) mock = MockMemcached() memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool( [(mock, mock)] * 2) - self.assertEquals(memcache_client.decr('some_key', delta=5), 0) - self.assertEquals(memcache_client.get('some_key'), '0') - self.assertEquals(memcache_client.incr('some_key', delta=15), 15) - self.assertEquals(memcache_client.get('some_key'), '15') - self.assertEquals(memcache_client.decr('some_key', delta=4), 11) - self.assertEquals(memcache_client.get('some_key'), '11') - self.assertEquals(memcache_client.decr('some_key', delta=15), 0) - self.assertEquals(memcache_client.get('some_key'), '0') + self.assertEqual(memcache_client.decr('some_key', delta=5), 0) + self.assertEqual(memcache_client.get('some_key'), '0') + self.assertEqual(memcache_client.incr('some_key', delta=15), 15) + self.assertEqual(memcache_client.get('some_key'), '15') + self.assertEqual(memcache_client.decr('some_key', delta=4), 11) + self.assertEqual(memcache_client.get('some_key'), '11') + self.assertEqual(memcache_client.decr('some_key', delta=15), 0) + self.assertEqual(memcache_client.get('some_key'), '0') mock.read_return_none = True self.assertRaises(memcached.MemcacheConnectionError, memcache_client.decr, 'some_key', delta=15) @@ -288,8 +288,8 @@ class TestMemcached(unittest.TestCase): memcache_client._client_cache['1.2.3.5:11211'] = MockedMemcachePool( [(mock1, mock1)]) memcache_client.set('some_key', [1, 2, 3]) - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) - self.assertEquals(mock1.exploded, True) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(mock1.exploded, True) def test_delete(self): memcache_client = memcached.MemcacheRing(['1.2.3.4:11211']) @@ -297,9 +297,9 @@ class TestMemcached(unittest.TestCase): memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool( [(mock, mock)] * 2) memcache_client.set('some_key', [1, 2, 3]) - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client.delete('some_key') - self.assertEquals(memcache_client.get('some_key'), None) + self.assertEqual(memcache_client.get('some_key'), None) def test_multi(self): memcache_client = memcached.MemcacheRing(['1.2.3.4:11211']) @@ -308,21 +308,21 @@ class TestMemcached(unittest.TestCase): [(mock, mock)] * 2) memcache_client.set_multi( {'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key') - self.assertEquals( + self.assertEqual( memcache_client.get_multi(('some_key2', 'some_key1'), 'multi_key'), [[4, 5, 6], [1, 2, 3]]) - self.assertEquals(mock.cache.values()[0][1], '0') - self.assertEquals(mock.cache.values()[1][1], '0') + self.assertEqual(mock.cache.values()[0][1], '0') + self.assertEqual(mock.cache.values()[1][1], '0') memcache_client.set_multi( {'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key', timeout=10) - self.assertEquals(mock.cache.values()[0][1], '10') - self.assertEquals(mock.cache.values()[1][1], '10') + self.assertEqual(mock.cache.values()[0][1], '10') + self.assertEqual(mock.cache.values()[1][1], '10') memcache_client.set_multi( {'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key', time=20) - self.assertEquals(mock.cache.values()[0][1], '20') - self.assertEquals(mock.cache.values()[1][1], '20') + self.assertEqual(mock.cache.values()[0][1], '20') + self.assertEqual(mock.cache.values()[1][1], '20') fortydays = 50 * 24 * 60 * 60 esttimeout = time.time() + fortydays @@ -333,7 +333,7 @@ class TestMemcached(unittest.TestCase): -1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1) self.assertTrue( -1 <= float(mock.cache.values()[1][1]) - esttimeout <= 1) - self.assertEquals(memcache_client.get_multi( + self.assertEqual(memcache_client.get_multi( ('some_key2', 'some_key1', 'not_exists'), 'multi_key'), [[4, 5, 6], [1, 2, 3], None]) @@ -344,18 +344,18 @@ class TestMemcached(unittest.TestCase): memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool( [(mock, mock)] * 2) memcache_client.set('some_key', [1, 2, 3]) - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client._allow_pickle = False memcache_client._allow_unpickle = True - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client._allow_unpickle = False - self.assertEquals(memcache_client.get('some_key'), None) + self.assertEqual(memcache_client.get('some_key'), None) memcache_client.set('some_key', [1, 2, 3]) - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client._allow_unpickle = True - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client._allow_pickle = True - self.assertEquals(memcache_client.get('some_key'), [1, 2, 3]) + self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) def test_connection_pooling(self): with patch('swift.common.memcached.socket') as mock_module: @@ -379,7 +379,7 @@ class TestMemcached(unittest.TestCase): memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'], connect_timeout=10) # sanity - self.assertEquals(1, len(memcache_client._client_cache)) + self.assertEqual(1, len(memcache_client._client_cache)) for server, pool in memcache_client._client_cache.items(): self.assertEqual(2, pool.max_size) diff --git a/test/unit/common/test_request_helpers.py b/test/unit/common/test_request_helpers.py index d2dc02c48b..9ca750d525 100644 --- a/test/unit/common/test_request_helpers.py +++ b/test/unit/common/test_request_helpers.py @@ -56,22 +56,22 @@ class TestRequestHelpers(unittest.TestCase): def test_strip_sys_meta_prefix(self): mt = 'sysmeta' for st in server_types: - self.assertEquals(strip_sys_meta_prefix(st, 'x-%s-%s-a' - % (st, mt)), 'a') + self.assertEqual(strip_sys_meta_prefix(st, 'x-%s-%s-a' + % (st, mt)), 'a') def test_strip_user_meta_prefix(self): mt = 'meta' for st in server_types: - self.assertEquals(strip_user_meta_prefix(st, 'x-%s-%s-a' - % (st, mt)), 'a') + self.assertEqual(strip_user_meta_prefix(st, 'x-%s-%s-a' + % (st, mt)), 'a') def test_remove_items(self): src = {'a': 'b', 'c': 'd'} test = lambda x: x == 'a' rem = remove_items(src, test) - self.assertEquals(src, {'c': 'd'}) - self.assertEquals(rem, {'a': 'b'}) + self.assertEqual(src, {'c': 'd'}) + self.assertEqual(rem, {'a': 'b'}) def test_copy_header_subset(self): src = {'a': 'b', diff --git a/test/unit/common/test_splice.py b/test/unit/common/test_splice.py index 745e7ea2a8..374f98a82f 100644 --- a/test/unit/common/test_splice.py +++ b/test/unit/common/test_splice.py @@ -104,7 +104,7 @@ class TestSplice(unittest.TestCase): self.assertEqual(res, (3, 6, None)) self.assertEqual(os.lseek(fd.fileno(), 0, os.SEEK_CUR), 0) - self.assertEquals(os.read(pa, 6), 'abcdef') + self.assertEqual(os.read(pa, 6), 'abcdef') def test_splice_pipe_to_file(self): '''Test `splice` from a pipe to a file''' diff --git a/test/unit/common/test_storage_policy.py b/test/unit/common/test_storage_policy.py index c7c0453c17..2d473f7dae 100644 --- a/test/unit/common/test_storage_policy.py +++ b/test/unit/common/test_storage_policy.py @@ -80,16 +80,16 @@ class TestStoragePolicies(unittest.TestCase): {'name': 'one'}, {'name': 'ten'}] swift_info = POLICIES.get_policy_info() - self.assertEquals(sorted(expect, key=lambda k: k['name']), - sorted(swift_info, key=lambda k: k['name'])) + self.assertEqual(sorted(expect, key=lambda k: k['name']), + sorted(swift_info, key=lambda k: k['name'])) @patch_policies def test_get_policy_string(self): - self.assertEquals(get_policy_string('something', 0), 'something') - self.assertEquals(get_policy_string('something', None), 'something') - self.assertEquals(get_policy_string('something', ''), 'something') - self.assertEquals(get_policy_string('something', 1), - 'something' + '-1') + self.assertEqual(get_policy_string('something', 0), 'something') + self.assertEqual(get_policy_string('something', None), 'something') + self.assertEqual(get_policy_string('something', ''), 'something') + self.assertEqual(get_policy_string('something', 1), + 'something' + '-1') self.assertRaises(PolicyError, get_policy_string, 'something', 99) @patch_policies @@ -177,16 +177,16 @@ class TestStoragePolicies(unittest.TestCase): StoragePolicy(1, 'one', False), StoragePolicy(2, 'two', False)] policies = StoragePolicyCollection(test_policies) - self.assertEquals(policies.default, test_policies[0]) - self.assertEquals(policies.default.name, 'zero') + self.assertEqual(policies.default, test_policies[0]) + self.assertEqual(policies.default.name, 'zero') # non-zero explicit default test_policies = [StoragePolicy(0, 'zero', False), StoragePolicy(1, 'one', False), StoragePolicy(2, 'two', True)] policies = StoragePolicyCollection(test_policies) - self.assertEquals(policies.default, test_policies[2]) - self.assertEquals(policies.default.name, 'two') + self.assertEqual(policies.default, test_policies[2]) + self.assertEqual(policies.default.name, 'two') # multiple defaults test_policies = [StoragePolicy(0, 'zero', False), @@ -199,8 +199,8 @@ class TestStoragePolicies(unittest.TestCase): # nothing specified test_policies = [] policies = StoragePolicyCollection(test_policies) - self.assertEquals(policies.default, policies[0]) - self.assertEquals(policies.default.name, 'Policy-0') + self.assertEqual(policies.default, policies[0]) + self.assertEqual(policies.default.name, 'Policy-0') # no default specified with only policy index 0 test_policies = [StoragePolicy(0, 'zero')] @@ -221,9 +221,9 @@ class TestStoragePolicies(unittest.TestCase): StoragePolicy(1, 'one', False), StoragePolicy(2, 'two', False, is_deprecated=True)] policies = StoragePolicyCollection(test_policies) - self.assertEquals(policies.default, test_policies[0]) - self.assertEquals(policies.default.name, 'zero') - self.assertEquals(len(policies), 3) + self.assertEqual(policies.default, test_policies[0]) + self.assertEqual(policies.default.name, 'zero') + self.assertEqual(len(policies), 3) # multiple policies requires default test_policies = [StoragePolicy(0, 'zero', False), @@ -280,7 +280,7 @@ class TestStoragePolicies(unittest.TestCase): # no type specified - make sure the policy is initialized to # DEFAULT_POLICY_TYPE test_policy = FakeStoragePolicy(0, 'zero', True) - self.assertEquals(test_policy.policy_type, 'fake') + self.assertEqual(test_policy.policy_type, 'fake') def test_validate_policies_type_invalid(self): class BogusStoragePolicy(FakeStoragePolicy): @@ -299,16 +299,16 @@ class TestStoragePolicies(unittest.TestCase): ec_ndata=10, ec_nparity=3), ] policies = StoragePolicyCollection(test_policies) - self.assertEquals(policies.get_by_index(0).policy_type, - REPL_POLICY) - self.assertEquals(policies.get_by_index(1).policy_type, - REPL_POLICY) - self.assertEquals(policies.get_by_index(2).policy_type, - REPL_POLICY) - self.assertEquals(policies.get_by_index(3).policy_type, - REPL_POLICY) - self.assertEquals(policies.get_by_index(10).policy_type, - EC_POLICY) + self.assertEqual(policies.get_by_index(0).policy_type, + REPL_POLICY) + self.assertEqual(policies.get_by_index(1).policy_type, + REPL_POLICY) + self.assertEqual(policies.get_by_index(2).policy_type, + REPL_POLICY) + self.assertEqual(policies.get_by_index(3).policy_type, + REPL_POLICY) + self.assertEqual(policies.get_by_index(10).policy_type, + EC_POLICY) def test_names_are_normalized(self): test_policies = [StoragePolicy(0, 'zero', True), @@ -650,24 +650,24 @@ class TestStoragePolicies(unittest.TestCase): """) policies = parse_storage_policies(conf) - self.assertEquals(True, policies.get_by_index(5).is_default) - self.assertEquals(False, policies.get_by_index(0).is_default) - self.assertEquals(False, policies.get_by_index(6).is_default) + self.assertEqual(True, policies.get_by_index(5).is_default) + self.assertEqual(False, policies.get_by_index(0).is_default) + self.assertEqual(False, policies.get_by_index(6).is_default) - self.assertEquals("object", policies.get_by_name("zero").ring_name) - self.assertEquals("object-5", policies.get_by_name("one").ring_name) - self.assertEquals("object-6", policies.get_by_name("apple").ring_name) + self.assertEqual("object", policies.get_by_name("zero").ring_name) + self.assertEqual("object-5", policies.get_by_name("one").ring_name) + self.assertEqual("object-6", policies.get_by_name("apple").ring_name) self.assertEqual(0, int(policies.get_by_name('zero'))) self.assertEqual(5, int(policies.get_by_name('one'))) self.assertEqual(6, int(policies.get_by_name('apple'))) - self.assertEquals("zero", policies.get_by_index(0).name) - self.assertEquals("zero", policies.get_by_index("0").name) - self.assertEquals("one", policies.get_by_index(5).name) - self.assertEquals("apple", policies.get_by_index(6).name) - self.assertEquals("zero", policies.get_by_index(None).name) - self.assertEquals("zero", policies.get_by_index('').name) + self.assertEqual("zero", policies.get_by_index(0).name) + self.assertEqual("zero", policies.get_by_index("0").name) + self.assertEqual("one", policies.get_by_index(5).name) + self.assertEqual("apple", policies.get_by_index(6).name) + self.assertEqual("zero", policies.get_by_index(None).name) + self.assertEqual("zero", policies.get_by_index('').name) self.assertEqual(policies.get_by_index(0), policies.legacy) diff --git a/test/unit/common/test_swob.py b/test/unit/common/test_swob.py index f57eabdf1f..489fa1dd28 100644 --- a/test/unit/common/test_swob.py +++ b/test/unit/common/test_swob.py @@ -34,13 +34,13 @@ class TestHeaderEnvironProxy(unittest.TestCase): proxy['Content-Length'] = 20 proxy['Content-Type'] = 'text/plain' proxy['Something-Else'] = 'somevalue' - self.assertEquals( + self.assertEqual( proxy.environ, {'CONTENT_LENGTH': '20', 'CONTENT_TYPE': 'text/plain', 'HTTP_SOMETHING_ELSE': 'somevalue'}) - self.assertEquals(proxy['content-length'], '20') - self.assertEquals(proxy['content-type'], 'text/plain') - self.assertEquals(proxy['something-else'], 'somevalue') + self.assertEqual(proxy['content-length'], '20') + self.assertEqual(proxy['content-type'], 'text/plain') + self.assertEqual(proxy['something-else'], 'somevalue') self.assertEqual(set(['Something-Else', 'Content-Length', 'Content-Type']), set(proxy.keys())) @@ -74,7 +74,7 @@ class TestHeaderEnvironProxy(unittest.TestCase): del proxy['Content-Length'] del proxy['Content-Type'] del proxy['Something-Else'] - self.assertEquals(proxy.environ, {}) + self.assertEqual(proxy.environ, {}) self.assertEqual(0, len(proxy)) def test_contains(self): @@ -93,7 +93,7 @@ class TestHeaderEnvironProxy(unittest.TestCase): proxy['Content-Length'] = 20 proxy['Content-Type'] = 'text/plain' proxy['Something-Else'] = 'somevalue' - self.assertEquals( + self.assertEqual( set(proxy.keys()), set(('Content-Length', 'Content-Type', 'Something-Else'))) @@ -104,23 +104,23 @@ class TestHeaderKeyDict(unittest.TestCase): headers['Content-Length'] = 0 headers['CONTENT-LENGTH'] = 10 headers['content-length'] = 20 - self.assertEquals(headers['Content-Length'], '20') - self.assertEquals(headers['content-length'], '20') - self.assertEquals(headers['CONTENT-LENGTH'], '20') + self.assertEqual(headers['Content-Length'], '20') + self.assertEqual(headers['content-length'], '20') + self.assertEqual(headers['CONTENT-LENGTH'], '20') def test_setdefault(self): headers = swift.common.swob.HeaderKeyDict() # it gets set headers.setdefault('x-rubber-ducky', 'the one') - self.assertEquals(headers['X-Rubber-Ducky'], 'the one') + self.assertEqual(headers['X-Rubber-Ducky'], 'the one') # it has the right return value ret = headers.setdefault('x-boat', 'dinghy') - self.assertEquals(ret, 'dinghy') + self.assertEqual(ret, 'dinghy') ret = headers.setdefault('x-boat', 'yacht') - self.assertEquals(ret, 'dinghy') + self.assertEqual(ret, 'dinghy') # shouldn't crash headers.setdefault('x-sir-not-appearing-in-this-request', None) @@ -136,22 +136,22 @@ class TestHeaderKeyDict(unittest.TestCase): headers = swift.common.swob.HeaderKeyDict() headers.update({'Content-Length': '0'}) headers.update([('Content-Type', 'text/plain')]) - self.assertEquals(headers['Content-Length'], '0') - self.assertEquals(headers['Content-Type'], 'text/plain') + self.assertEqual(headers['Content-Length'], '0') + self.assertEqual(headers['Content-Type'], 'text/plain') def test_get(self): headers = swift.common.swob.HeaderKeyDict() headers['content-length'] = 20 - self.assertEquals(headers.get('CONTENT-LENGTH'), '20') - self.assertEquals(headers.get('something-else'), None) - self.assertEquals(headers.get('something-else', True), True) + self.assertEqual(headers.get('CONTENT-LENGTH'), '20') + self.assertEqual(headers.get('something-else'), None) + self.assertEqual(headers.get('something-else', True), True) def test_keys(self): headers = swift.common.swob.HeaderKeyDict() headers['content-length'] = 20 headers['cOnTent-tYpe'] = 'text/plain' headers['SomeThing-eLse'] = 'somevalue' - self.assertEquals( + self.assertEqual( set(headers.keys()), set(('Content-Length', 'Content-Type', 'Something-Else'))) @@ -159,106 +159,106 @@ class TestHeaderKeyDict(unittest.TestCase): class TestRange(unittest.TestCase): def test_range(self): range = swift.common.swob.Range('bytes=1-7') - self.assertEquals(range.ranges[0], (1, 7)) + self.assertEqual(range.ranges[0], (1, 7)) def test_upsidedown_range(self): range = swift.common.swob.Range('bytes=5-10') - self.assertEquals(range.ranges_for_length(2), []) + self.assertEqual(range.ranges_for_length(2), []) def test_str(self): for range_str in ('bytes=1-7', 'bytes=1-', 'bytes=-1', 'bytes=1-7,9-12', 'bytes=-7,9-'): range = swift.common.swob.Range(range_str) - self.assertEquals(str(range), range_str) + self.assertEqual(str(range), range_str) def test_ranges_for_length(self): range = swift.common.swob.Range('bytes=1-7') - self.assertEquals(range.ranges_for_length(10), [(1, 8)]) - self.assertEquals(range.ranges_for_length(5), [(1, 5)]) - self.assertEquals(range.ranges_for_length(None), None) + self.assertEqual(range.ranges_for_length(10), [(1, 8)]) + self.assertEqual(range.ranges_for_length(5), [(1, 5)]) + self.assertEqual(range.ranges_for_length(None), None) def test_ranges_for_large_length(self): range = swift.common.swob.Range('bytes=-1000000000000000000000000000') - self.assertEquals(range.ranges_for_length(100), [(0, 100)]) + self.assertEqual(range.ranges_for_length(100), [(0, 100)]) def test_ranges_for_length_no_end(self): range = swift.common.swob.Range('bytes=1-') - self.assertEquals(range.ranges_for_length(10), [(1, 10)]) - self.assertEquals(range.ranges_for_length(5), [(1, 5)]) - self.assertEquals(range.ranges_for_length(None), None) + self.assertEqual(range.ranges_for_length(10), [(1, 10)]) + self.assertEqual(range.ranges_for_length(5), [(1, 5)]) + self.assertEqual(range.ranges_for_length(None), None) # This used to freak out: range = swift.common.swob.Range('bytes=100-') - self.assertEquals(range.ranges_for_length(5), []) - self.assertEquals(range.ranges_for_length(None), None) + self.assertEqual(range.ranges_for_length(5), []) + self.assertEqual(range.ranges_for_length(None), None) range = swift.common.swob.Range('bytes=4-6,100-') - self.assertEquals(range.ranges_for_length(5), [(4, 5)]) + self.assertEqual(range.ranges_for_length(5), [(4, 5)]) def test_ranges_for_length_no_start(self): range = swift.common.swob.Range('bytes=-7') - self.assertEquals(range.ranges_for_length(10), [(3, 10)]) - self.assertEquals(range.ranges_for_length(5), [(0, 5)]) - self.assertEquals(range.ranges_for_length(None), None) + self.assertEqual(range.ranges_for_length(10), [(3, 10)]) + self.assertEqual(range.ranges_for_length(5), [(0, 5)]) + self.assertEqual(range.ranges_for_length(None), None) range = swift.common.swob.Range('bytes=4-6,-100') - self.assertEquals(range.ranges_for_length(5), [(4, 5), (0, 5)]) + self.assertEqual(range.ranges_for_length(5), [(4, 5), (0, 5)]) def test_ranges_for_length_multi(self): range = swift.common.swob.Range('bytes=-20,4-') - self.assertEquals(len(range.ranges_for_length(200)), 2) + self.assertEqual(len(range.ranges_for_length(200)), 2) # the actual length greater than each range element - self.assertEquals(range.ranges_for_length(200), [(180, 200), (4, 200)]) + self.assertEqual(range.ranges_for_length(200), [(180, 200), (4, 200)]) range = swift.common.swob.Range('bytes=30-150,-10') - self.assertEquals(len(range.ranges_for_length(200)), 2) + self.assertEqual(len(range.ranges_for_length(200)), 2) # the actual length lands in the middle of a range - self.assertEquals(range.ranges_for_length(90), [(30, 90), (80, 90)]) + self.assertEqual(range.ranges_for_length(90), [(30, 90), (80, 90)]) # the actual length greater than any of the range - self.assertEquals(range.ranges_for_length(200), - [(30, 151), (190, 200)]) + self.assertEqual(range.ranges_for_length(200), + [(30, 151), (190, 200)]) - self.assertEquals(range.ranges_for_length(None), None) + self.assertEqual(range.ranges_for_length(None), None) def test_ranges_for_length_edges(self): range = swift.common.swob.Range('bytes=0-1, -7') - self.assertEquals(range.ranges_for_length(10), - [(0, 2), (3, 10)]) + self.assertEqual(range.ranges_for_length(10), + [(0, 2), (3, 10)]) range = swift.common.swob.Range('bytes=-7, 0-1') - self.assertEquals(range.ranges_for_length(10), - [(3, 10), (0, 2)]) + self.assertEqual(range.ranges_for_length(10), + [(3, 10), (0, 2)]) range = swift.common.swob.Range('bytes=-7, 0-1') - self.assertEquals(range.ranges_for_length(5), - [(0, 5), (0, 2)]) + self.assertEqual(range.ranges_for_length(5), + [(0, 5), (0, 2)]) def test_ranges_for_length_overlapping(self): # Fewer than 3 overlaps is okay range = swift.common.swob.Range('bytes=10-19,15-24') - self.assertEquals(range.ranges_for_length(100), - [(10, 20), (15, 25)]) + self.assertEqual(range.ranges_for_length(100), + [(10, 20), (15, 25)]) range = swift.common.swob.Range('bytes=10-19,15-24,20-29') - self.assertEquals(range.ranges_for_length(100), - [(10, 20), (15, 25), (20, 30)]) + self.assertEqual(range.ranges_for_length(100), + [(10, 20), (15, 25), (20, 30)]) # Adjacent ranges, though suboptimal, don't overlap range = swift.common.swob.Range('bytes=10-19,20-29,30-39') - self.assertEquals(range.ranges_for_length(100), - [(10, 20), (20, 30), (30, 40)]) + self.assertEqual(range.ranges_for_length(100), + [(10, 20), (20, 30), (30, 40)]) # Ranges that share a byte do overlap range = swift.common.swob.Range('bytes=10-20,20-30,30-40,40-50') - self.assertEquals(range.ranges_for_length(100), []) + self.assertEqual(range.ranges_for_length(100), []) # With suffix byte range specs (e.g. bytes=-2), make sure that we # correctly determine overlapping-ness based on the entity length range = swift.common.swob.Range('bytes=10-15,15-20,30-39,-9') - self.assertEquals(range.ranges_for_length(100), - [(10, 16), (15, 21), (30, 40), (91, 100)]) - self.assertEquals(range.ranges_for_length(20), []) + self.assertEqual(range.ranges_for_length(100), + [(10, 16), (15, 21), (30, 40), (91, 100)]) + self.assertEqual(range.ranges_for_length(20), []) def test_ranges_for_length_nonascending(self): few_ranges = ("bytes=100-109,200-209,300-309,500-509," @@ -266,12 +266,12 @@ class TestRange(unittest.TestCase): many_ranges = few_ranges + ",800-809" range = swift.common.swob.Range(few_ranges) - self.assertEquals(range.ranges_for_length(100000), - [(100, 110), (200, 210), (300, 310), (500, 510), - (400, 410), (600, 610), (700, 710)]) + self.assertEqual(range.ranges_for_length(100000), + [(100, 110), (200, 210), (300, 310), (500, 510), + (400, 410), (600, 610), (700, 710)]) range = swift.common.swob.Range(many_ranges) - self.assertEquals(range.ranges_for_length(100000), []) + self.assertEqual(range.ranges_for_length(100000), []) def test_ranges_for_length_too_many(self): at_the_limit_ranges = ( @@ -280,10 +280,10 @@ class TestRange(unittest.TestCase): too_many_ranges = at_the_limit_ranges + ",10000000-10000009" rng = swift.common.swob.Range(at_the_limit_ranges) - self.assertEquals(len(rng.ranges_for_length(1000000000)), 50) + self.assertEqual(len(rng.ranges_for_length(1000000000)), 50) rng = swift.common.swob.Range(too_many_ranges) - self.assertEquals(rng.ranges_for_length(1000000000), []) + self.assertEqual(rng.ranges_for_length(1000000000), []) def test_range_invalid_syntax(self): @@ -318,7 +318,7 @@ class TestRange(unittest.TestCase): class TestMatch(unittest.TestCase): def test_match(self): match = swift.common.swob.Match('"a", "b"') - self.assertEquals(match.tags, set(('a', 'b'))) + self.assertEqual(match.tags, set(('a', 'b'))) self.assertTrue('a' in match) self.assertTrue('b' in match) self.assertTrue('c' not in match) @@ -331,7 +331,7 @@ class TestMatch(unittest.TestCase): def test_match_noquote(self): match = swift.common.swob.Match('a, b') - self.assertEquals(match.tags, set(('a', 'b'))) + self.assertEqual(match.tags, set(('a', 'b'))) self.assertTrue('a' in match) self.assertTrue('b' in match) self.assertTrue('c' not in match) @@ -346,7 +346,7 @@ class TestAccept(unittest.TestCase): acc = swift.common.swob.Accept(accept) match = acc.best_match(['text/plain', 'application/json', 'application/xml', 'text/xml']) - self.assertEquals(match, 'application/json') + self.assertEqual(match, 'application/json') def test_accept_plain(self): for accept in ('', 'text/plain', 'application/xml;q=0.8,*/*;q=0.9', @@ -355,7 +355,7 @@ class TestAccept(unittest.TestCase): acc = swift.common.swob.Accept(accept) match = acc.best_match(['text/plain', 'application/json', 'application/xml', 'text/xml']) - self.assertEquals(match, 'text/plain') + self.assertEqual(match, 'text/plain') def test_accept_xml(self): for accept in ('application/xml', 'application/xml;q=1.0,*/*;q=0.9', @@ -366,7 +366,7 @@ class TestAccept(unittest.TestCase): acc = swift.common.swob.Accept(accept) match = acc.best_match(['text/plain', 'application/xml', 'text/xml']) - self.assertEquals(match, 'application/xml') + self.assertEqual(match, 'application/xml') def test_accept_invalid(self): for accept in ('*', 'text/plain,,', 'some stuff', @@ -378,11 +378,11 @@ class TestAccept(unittest.TestCase): acc = swift.common.swob.Accept(accept) match = acc.best_match(['text/plain', 'application/xml', 'text/xml']) - self.assertEquals(match, None) + self.assertEqual(match, None) def test_repr(self): acc = swift.common.swob.Accept("application/json") - self.assertEquals(repr(acc), "application/json") + self.assertEqual(repr(acc), "application/json") class TestRequest(unittest.TestCase): @@ -390,46 +390,46 @@ class TestRequest(unittest.TestCase): req = swift.common.swob.Request.blank( '/', environ={'REQUEST_METHOD': 'POST'}, headers={'Content-Type': 'text/plain'}, body='hi') - self.assertEquals(req.path_info, '/') - self.assertEquals(req.body, 'hi') - self.assertEquals(req.headers['Content-Type'], 'text/plain') - self.assertEquals(req.method, 'POST') + self.assertEqual(req.path_info, '/') + self.assertEqual(req.body, 'hi') + self.assertEqual(req.headers['Content-Type'], 'text/plain') + self.assertEqual(req.method, 'POST') def test_blank_req_environ_property_args(self): blank = swift.common.swob.Request.blank req = blank('/', method='PATCH') - self.assertEquals(req.method, 'PATCH') - self.assertEquals(req.environ['REQUEST_METHOD'], 'PATCH') + self.assertEqual(req.method, 'PATCH') + self.assertEqual(req.environ['REQUEST_METHOD'], 'PATCH') req = blank('/', referer='http://example.com') - self.assertEquals(req.referer, 'http://example.com') - self.assertEquals(req.referrer, 'http://example.com') - self.assertEquals(req.environ['HTTP_REFERER'], 'http://example.com') - self.assertEquals(req.headers['Referer'], 'http://example.com') + self.assertEqual(req.referer, 'http://example.com') + self.assertEqual(req.referrer, 'http://example.com') + self.assertEqual(req.environ['HTTP_REFERER'], 'http://example.com') + self.assertEqual(req.headers['Referer'], 'http://example.com') req = blank('/', script_name='/application') - self.assertEquals(req.script_name, '/application') - self.assertEquals(req.environ['SCRIPT_NAME'], '/application') + self.assertEqual(req.script_name, '/application') + self.assertEqual(req.environ['SCRIPT_NAME'], '/application') req = blank('/', host='www.example.com') - self.assertEquals(req.host, 'www.example.com') - self.assertEquals(req.environ['HTTP_HOST'], 'www.example.com') - self.assertEquals(req.headers['Host'], 'www.example.com') + self.assertEqual(req.host, 'www.example.com') + self.assertEqual(req.environ['HTTP_HOST'], 'www.example.com') + self.assertEqual(req.headers['Host'], 'www.example.com') req = blank('/', remote_addr='127.0.0.1') - self.assertEquals(req.remote_addr, '127.0.0.1') - self.assertEquals(req.environ['REMOTE_ADDR'], '127.0.0.1') + self.assertEqual(req.remote_addr, '127.0.0.1') + self.assertEqual(req.environ['REMOTE_ADDR'], '127.0.0.1') req = blank('/', remote_user='username') - self.assertEquals(req.remote_user, 'username') - self.assertEquals(req.environ['REMOTE_USER'], 'username') + self.assertEqual(req.remote_user, 'username') + self.assertEqual(req.environ['REMOTE_USER'], 'username') req = blank('/', user_agent='curl/7.22.0 (x86_64-pc-linux-gnu)') - self.assertEquals(req.user_agent, 'curl/7.22.0 (x86_64-pc-linux-gnu)') - self.assertEquals(req.environ['HTTP_USER_AGENT'], - 'curl/7.22.0 (x86_64-pc-linux-gnu)') - self.assertEquals(req.headers['User-Agent'], - 'curl/7.22.0 (x86_64-pc-linux-gnu)') + self.assertEqual(req.user_agent, 'curl/7.22.0 (x86_64-pc-linux-gnu)') + self.assertEqual(req.environ['HTTP_USER_AGENT'], + 'curl/7.22.0 (x86_64-pc-linux-gnu)') + self.assertEqual(req.headers['User-Agent'], + 'curl/7.22.0 (x86_64-pc-linux-gnu)') req = blank('/', query_string='a=b&c=d') - self.assertEquals(req.query_string, 'a=b&c=d') - self.assertEquals(req.environ['QUERY_STRING'], 'a=b&c=d') + self.assertEqual(req.query_string, 'a=b&c=d') + self.assertEqual(req.environ['QUERY_STRING'], 'a=b&c=d') req = blank('/', if_match='*') - self.assertEquals(req.environ['HTTP_IF_MATCH'], '*') - self.assertEquals(req.headers['If-Match'], '*') + self.assertEqual(req.environ['HTTP_IF_MATCH'], '*') + self.assertEqual(req.headers['If-Match'], '*') # multiple environ property kwargs req = blank('/', method='PATCH', referer='http://example.com', @@ -437,23 +437,23 @@ class TestRequest(unittest.TestCase): remote_addr='127.0.0.1', remote_user='username', user_agent='curl/7.22.0 (x86_64-pc-linux-gnu)', query_string='a=b&c=d', if_match='*') - self.assertEquals(req.method, 'PATCH') - self.assertEquals(req.referer, 'http://example.com') - self.assertEquals(req.script_name, '/application') - self.assertEquals(req.host, 'www.example.com') - self.assertEquals(req.remote_addr, '127.0.0.1') - self.assertEquals(req.remote_user, 'username') - self.assertEquals(req.user_agent, 'curl/7.22.0 (x86_64-pc-linux-gnu)') - self.assertEquals(req.query_string, 'a=b&c=d') - self.assertEquals(req.environ['QUERY_STRING'], 'a=b&c=d') + self.assertEqual(req.method, 'PATCH') + self.assertEqual(req.referer, 'http://example.com') + self.assertEqual(req.script_name, '/application') + self.assertEqual(req.host, 'www.example.com') + self.assertEqual(req.remote_addr, '127.0.0.1') + self.assertEqual(req.remote_user, 'username') + self.assertEqual(req.user_agent, 'curl/7.22.0 (x86_64-pc-linux-gnu)') + self.assertEqual(req.query_string, 'a=b&c=d') + self.assertEqual(req.environ['QUERY_STRING'], 'a=b&c=d') def test_invalid_req_environ_property_args(self): # getter only property try: swift.common.swob.Request.blank('/', params={'a': 'b'}) except TypeError as e: - self.assertEquals("got unexpected keyword argument 'params'", - str(e)) + self.assertEqual("got unexpected keyword argument 'params'", + str(e)) else: self.assertTrue(False, "invalid req_environ_property " "didn't raise error!") @@ -461,8 +461,8 @@ class TestRequest(unittest.TestCase): try: swift.common.swob.Request.blank('/', _params_cache={'a': 'b'}) except TypeError as e: - self.assertEquals("got unexpected keyword " - "argument '_params_cache'", str(e)) + self.assertEqual("got unexpected keyword " + "argument '_params_cache'", str(e)) else: self.assertTrue(False, "invalid req_environ_property " "didn't raise error!") @@ -470,8 +470,8 @@ class TestRequest(unittest.TestCase): try: swift.common.swob.Request.blank('/', params_cache={'a': 'b'}) except TypeError as e: - self.assertEquals("got unexpected keyword " - "argument 'params_cache'", str(e)) + self.assertEqual("got unexpected keyword " + "argument 'params_cache'", str(e)) else: self.assertTrue(False, "invalid req_environ_property " "didn't raise error!") @@ -480,8 +480,8 @@ class TestRequest(unittest.TestCase): swift.common.swob.Request.blank( '/', as_referer='GET http://example.com') except TypeError as e: - self.assertEquals("got unexpected keyword " - "argument 'as_referer'", str(e)) + self.assertEqual("got unexpected keyword " + "argument 'as_referer'", str(e)) else: self.assertTrue(False, "invalid req_environ_property " "didn't raise error!") @@ -489,23 +489,23 @@ class TestRequest(unittest.TestCase): def test_blank_path_info_precedence(self): blank = swift.common.swob.Request.blank req = blank('/a') - self.assertEquals(req.path_info, '/a') + self.assertEqual(req.path_info, '/a') req = blank('/a', environ={'PATH_INFO': '/a/c'}) - self.assertEquals(req.path_info, '/a/c') + self.assertEqual(req.path_info, '/a/c') req = blank('/a', environ={'PATH_INFO': '/a/c'}, path_info='/a/c/o') - self.assertEquals(req.path_info, '/a/c/o') + self.assertEqual(req.path_info, '/a/c/o') req = blank('/a', path_info='/a/c/o') - self.assertEquals(req.path_info, '/a/c/o') + self.assertEqual(req.path_info, '/a/c/o') def test_blank_body_precedence(self): req = swift.common.swob.Request.blank( '/', environ={'REQUEST_METHOD': 'POST', 'wsgi.input': BytesIO(b'')}, headers={'Content-Type': 'text/plain'}, body='hi') - self.assertEquals(req.path_info, '/') - self.assertEquals(req.body, 'hi') - self.assertEquals(req.headers['Content-Type'], 'text/plain') - self.assertEquals(req.method, 'POST') + self.assertEqual(req.path_info, '/') + self.assertEqual(req.body, 'hi') + self.assertEqual(req.headers['Content-Type'], 'text/plain') + self.assertEqual(req.method, 'POST') body_file = BytesIO(b'asdf') req = swift.common.swob.Request.blank( '/', environ={'REQUEST_METHOD': 'POST', @@ -518,31 +518,31 @@ class TestRequest(unittest.TestCase): 'wsgi.input': BytesIO(b'')}, headers={'Content-Type': 'text/plain'}, body='hi', content_length=3) - self.assertEquals(req.content_length, 3) - self.assertEquals(len(req.body), 2) + self.assertEqual(req.content_length, 3) + self.assertEqual(len(req.body), 2) def test_blank_parsing(self): req = swift.common.swob.Request.blank('http://test.com/') - self.assertEquals(req.environ['wsgi.url_scheme'], 'http') - self.assertEquals(req.environ['SERVER_PORT'], '80') - self.assertEquals(req.environ['SERVER_NAME'], 'test.com') + self.assertEqual(req.environ['wsgi.url_scheme'], 'http') + self.assertEqual(req.environ['SERVER_PORT'], '80') + self.assertEqual(req.environ['SERVER_NAME'], 'test.com') req = swift.common.swob.Request.blank('https://test.com:456/') - self.assertEquals(req.environ['wsgi.url_scheme'], 'https') - self.assertEquals(req.environ['SERVER_PORT'], '456') + self.assertEqual(req.environ['wsgi.url_scheme'], 'https') + self.assertEqual(req.environ['SERVER_PORT'], '456') req = swift.common.swob.Request.blank('test.com/') - self.assertEquals(req.environ['wsgi.url_scheme'], 'http') - self.assertEquals(req.environ['SERVER_PORT'], '80') - self.assertEquals(req.environ['PATH_INFO'], 'test.com/') + self.assertEqual(req.environ['wsgi.url_scheme'], 'http') + self.assertEqual(req.environ['SERVER_PORT'], '80') + self.assertEqual(req.environ['PATH_INFO'], 'test.com/') self.assertRaises(TypeError, swift.common.swob.Request.blank, 'ftp://test.com/') def test_params(self): req = swift.common.swob.Request.blank('/?a=b&c=d') - self.assertEquals(req.params['a'], 'b') - self.assertEquals(req.params['c'], 'd') + self.assertEqual(req.params['a'], 'b') + self.assertEqual(req.params['c'], 'd') def test_timestamp_missing(self): req = swift.common.swob.Request.blank('/') @@ -565,46 +565,46 @@ class TestRequest(unittest.TestCase): def test_path(self): req = swift.common.swob.Request.blank('/hi?a=b&c=d') - self.assertEquals(req.path, '/hi') + self.assertEqual(req.path, '/hi') req = swift.common.swob.Request.blank( '/', environ={'SCRIPT_NAME': '/hi', 'PATH_INFO': '/there'}) - self.assertEquals(req.path, '/hi/there') + self.assertEqual(req.path, '/hi/there') def test_path_question_mark(self): req = swift.common.swob.Request.blank('/test%3Ffile') # This tests that .blank unquotes the path when setting PATH_INFO - self.assertEquals(req.environ['PATH_INFO'], '/test?file') + self.assertEqual(req.environ['PATH_INFO'], '/test?file') # This tests that .path requotes it - self.assertEquals(req.path, '/test%3Ffile') + self.assertEqual(req.path, '/test%3Ffile') def test_path_info_pop(self): req = swift.common.swob.Request.blank('/hi/there') - self.assertEquals(req.path_info_pop(), 'hi') - self.assertEquals(req.path_info, '/there') - self.assertEquals(req.script_name, '/hi') + self.assertEqual(req.path_info_pop(), 'hi') + self.assertEqual(req.path_info, '/there') + self.assertEqual(req.script_name, '/hi') def test_bad_path_info_pop(self): req = swift.common.swob.Request.blank('blahblah') - self.assertEquals(req.path_info_pop(), None) + self.assertEqual(req.path_info_pop(), None) def test_path_info_pop_last(self): req = swift.common.swob.Request.blank('/last') - self.assertEquals(req.path_info_pop(), 'last') - self.assertEquals(req.path_info, '') - self.assertEquals(req.script_name, '/last') + self.assertEqual(req.path_info_pop(), 'last') + self.assertEqual(req.path_info, '') + self.assertEqual(req.script_name, '/last') def test_path_info_pop_none(self): req = swift.common.swob.Request.blank('/') - self.assertEquals(req.path_info_pop(), '') - self.assertEquals(req.path_info, '') - self.assertEquals(req.script_name, '/') + self.assertEqual(req.path_info_pop(), '') + self.assertEqual(req.path_info, '') + self.assertEqual(req.script_name, '/') def test_copy_get(self): req = swift.common.swob.Request.blank( '/hi/there', environ={'REQUEST_METHOD': 'POST'}) - self.assertEquals(req.method, 'POST') + self.assertEqual(req.method, 'POST') req2 = req.copy_get() - self.assertEquals(req2.method, 'GET') + self.assertEqual(req2.method, 'GET') def test_get_response(self): def test_app(environ, start_response): @@ -613,18 +613,18 @@ class TestRequest(unittest.TestCase): req = swift.common.swob.Request.blank('/') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.body, 'hi') def test_401_unauthorized(self): # No request environment resp = swift.common.swob.HTTPUnauthorized() - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) # Request environment req = swift.common.swob.Request.blank('/') resp = swift.common.swob.HTTPUnauthorized(request=req) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) def test_401_valid_account_path(self): @@ -636,18 +636,18 @@ class TestRequest(unittest.TestCase): # Request environment contains valid account in path req = swift.common.swob.Request.blank('/v1/account-name') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="account-name"', - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="account-name"', + resp.headers['Www-Authenticate']) # Request environment contains valid account/container in path req = swift.common.swob.Request.blank('/v1/account-name/c') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="account-name"', - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="account-name"', + resp.headers['Www-Authenticate']) def test_401_invalid_path(self): @@ -658,10 +658,10 @@ class TestRequest(unittest.TestCase): # Request environment contains bad path req = swift.common.swob.Request.blank('/random') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="unknown"', - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="unknown"', + resp.headers['Www-Authenticate']) def test_401_non_keystone_auth_path(self): @@ -672,18 +672,18 @@ class TestRequest(unittest.TestCase): # Request to get token req = swift.common.swob.Request.blank('/v1.0/auth') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="unknown"', - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="unknown"', + resp.headers['Www-Authenticate']) # Other form of path req = swift.common.swob.Request.blank('/auth/v1.0') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="unknown"', - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="unknown"', + resp.headers['Www-Authenticate']) def test_401_www_authenticate_exists(self): @@ -695,10 +695,10 @@ class TestRequest(unittest.TestCase): # Auth middleware sets own Www-Authenticate req = swift.common.swob.Request.blank('/auth/v1.0') resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Me realm="whatever"', - resp.headers['Www-Authenticate']) + self.assertEqual('Me realm="whatever"', + resp.headers['Www-Authenticate']) def test_401_www_authenticate_is_quoted(self): @@ -710,17 +710,17 @@ class TestRequest(unittest.TestCase): quoted_hacker = quote(hacker) req = swift.common.swob.Request.blank('/v1/' + hacker) resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="%s"' % quoted_hacker, - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="%s"' % quoted_hacker, + resp.headers['Www-Authenticate']) req = swift.common.swob.Request.blank('/v1/' + quoted_hacker) resp = req.get_response(test_app) - self.assertEquals(resp.status_int, 401) + self.assertEqual(resp.status_int, 401) self.assertTrue('Www-Authenticate' in resp.headers) - self.assertEquals('Swift realm="%s"' % quoted_hacker, - resp.headers['Www-Authenticate']) + self.assertEqual('Swift realm="%s"' % quoted_hacker, + resp.headers['Www-Authenticate']) def test_not_401(self): @@ -736,18 +736,18 @@ class TestRequest(unittest.TestCase): def test_properties(self): req = swift.common.swob.Request.blank('/hi/there', body='hi') - self.assertEquals(req.body, 'hi') - self.assertEquals(req.content_length, 2) + self.assertEqual(req.body, 'hi') + self.assertEqual(req.content_length, 2) req.remote_addr = 'something' - self.assertEquals(req.environ['REMOTE_ADDR'], 'something') + self.assertEqual(req.environ['REMOTE_ADDR'], 'something') req.body = 'whatever' - self.assertEquals(req.content_length, 8) - self.assertEquals(req.body, 'whatever') - self.assertEquals(req.method, 'GET') + self.assertEqual(req.content_length, 8) + self.assertEqual(req.body, 'whatever') + self.assertEqual(req.method, 'GET') req.range = 'bytes=1-7' - self.assertEquals(req.range.ranges[0], (1, 7)) + self.assertEqual(req.range.ranges[0], (1, 7)) self.assertTrue('Range' in req.headers) req.range = None @@ -760,11 +760,11 @@ class TestRequest(unittest.TestCase): self.assertTrue(isinstance(req.if_unmodified_since, datetime.datetime)) if_unmodified_since = req.if_unmodified_since req.if_unmodified_since = if_unmodified_since - self.assertEquals(if_unmodified_since, req.if_unmodified_since) + self.assertEqual(if_unmodified_since, req.if_unmodified_since) req.if_unmodified_since = 'something' - self.assertEquals(req.headers['If-Unmodified-Since'], 'something') - self.assertEquals(req.if_unmodified_since, None) + self.assertEqual(req.headers['If-Unmodified-Since'], 'something') + self.assertEqual(req.if_unmodified_since, None) self.assertTrue('If-Unmodified-Since' in req.headers) req.if_unmodified_since = None @@ -781,7 +781,7 @@ class TestRequest(unittest.TestCase): def test_bad_range(self): req = swift.common.swob.Request.blank('/hi/there', body='hi') req.range = 'bad range' - self.assertEquals(req.range, None) + self.assertEqual(req.range, None) def test_accept_header(self): req = swift.common.swob.Request({'REQUEST_METHOD': 'GET', @@ -856,9 +856,9 @@ class TestRequest(unittest.TestCase): self.assertRaises(ValueError, _test_split_path, '') self.assertRaises(ValueError, _test_split_path, '/') self.assertRaises(ValueError, _test_split_path, '//') - self.assertEquals(_test_split_path('/a'), ['a']) + self.assertEqual(_test_split_path('/a'), ['a']) self.assertRaises(ValueError, _test_split_path, '//a') - self.assertEquals(_test_split_path('/a/'), ['a']) + self.assertEqual(_test_split_path('/a/'), ['a']) self.assertRaises(ValueError, _test_split_path, '/a/c') self.assertRaises(ValueError, _test_split_path, '//c') self.assertRaises(ValueError, _test_split_path, '/a/c/') @@ -866,33 +866,33 @@ class TestRequest(unittest.TestCase): self.assertRaises(ValueError, _test_split_path, '/a', 2) self.assertRaises(ValueError, _test_split_path, '/a', 2, 3) self.assertRaises(ValueError, _test_split_path, '/a', 2, 3, True) - self.assertEquals(_test_split_path('/a/c', 2), ['a', 'c']) - self.assertEquals(_test_split_path('/a/c/o', 3), ['a', 'c', 'o']) + self.assertEqual(_test_split_path('/a/c', 2), ['a', 'c']) + self.assertEqual(_test_split_path('/a/c/o', 3), ['a', 'c', 'o']) self.assertRaises(ValueError, _test_split_path, '/a/c/o/r', 3, 3) - self.assertEquals(_test_split_path('/a/c/o/r', 3, 3, True), - ['a', 'c', 'o/r']) - self.assertEquals(_test_split_path('/a/c', 2, 3, True), - ['a', 'c', None]) + self.assertEqual(_test_split_path('/a/c/o/r', 3, 3, True), + ['a', 'c', 'o/r']) + self.assertEqual(_test_split_path('/a/c', 2, 3, True), + ['a', 'c', None]) self.assertRaises(ValueError, _test_split_path, '/a', 5, 4) - self.assertEquals(_test_split_path('/a/c/', 2), ['a', 'c']) - self.assertEquals(_test_split_path('/a/c/', 2, 3), ['a', 'c', '']) + self.assertEqual(_test_split_path('/a/c/', 2), ['a', 'c']) + self.assertEqual(_test_split_path('/a/c/', 2, 3), ['a', 'c', '']) try: _test_split_path('o\nn e', 2) except ValueError as err: - self.assertEquals(str(err), 'Invalid path: o%0An%20e') + self.assertEqual(str(err), 'Invalid path: o%0An%20e') try: _test_split_path('o\nn e', 2, 3, True) except ValueError as err: - self.assertEquals(str(err), 'Invalid path: o%0An%20e') + self.assertEqual(str(err), 'Invalid path: o%0An%20e') def test_unicode_path(self): req = swift.common.swob.Request.blank(u'/\u2661') - self.assertEquals(req.path, quote(u'/\u2661'.encode('utf-8'))) + self.assertEqual(req.path, quote(u'/\u2661'.encode('utf-8'))) def test_unicode_query(self): req = swift.common.swob.Request.blank(u'/') req.query_string = u'x=\u2661' - self.assertEquals(req.params['x'], u'\u2661'.encode('utf-8')) + self.assertEqual(req.params['x'], u'\u2661'.encode('utf-8')) def test_url2(self): pi = '/hi/there' @@ -953,19 +953,19 @@ class TestRequest(unittest.TestCase): req = swift.common.swob.Request.blank( u'/', environ={'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/'}) - self.assertEquals(req.message_length(), None) + self.assertEqual(req.message_length(), None) req = swift.common.swob.Request.blank( u'/', environ={'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/'}, body='x' * 42) - self.assertEquals(req.message_length(), 42) + self.assertEqual(req.message_length(), 42) req.headers['Content-Length'] = 'abc' try: req.message_length() except ValueError as e: - self.assertEquals(str(e), "Invalid Content-Length header value") + self.assertEqual(str(e), "Invalid Content-Length header value") else: self.fail("Expected a ValueError raised for 'abc'") @@ -975,14 +975,14 @@ class TestRequest(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/'}, headers={'transfer-encoding': 'chunked'}, body='x' * 42) - self.assertEquals(req.message_length(), None) + self.assertEqual(req.message_length(), None) req.headers['Transfer-Encoding'] = 'gzip,chunked' try: req.message_length() except AttributeError as e: - self.assertEquals(str(e), "Unsupported Transfer-Coding header" - " value specified in Transfer-Encoding header") + self.assertEqual(str(e), "Unsupported Transfer-Coding header" + " value specified in Transfer-Encoding header") else: self.fail("Expected an AttributeError raised for 'gzip'") @@ -990,7 +990,7 @@ class TestRequest(unittest.TestCase): try: req.message_length() except ValueError as e: - self.assertEquals(str(e), "Invalid Transfer-Encoding header value") + self.assertEqual(str(e), "Invalid Transfer-Encoding header value") else: self.fail("Expected a ValueError raised for 'gzip'") @@ -998,8 +998,8 @@ class TestRequest(unittest.TestCase): try: req.message_length() except AttributeError as e: - self.assertEquals(str(e), "Unsupported Transfer-Coding header" - " value specified in Transfer-Encoding header") + self.assertEqual(str(e), "Unsupported Transfer-Coding header" + " value specified in Transfer-Encoding header") else: self.fail("Expected an AttributeError raised for 'gzip,identity'") @@ -1013,13 +1013,13 @@ class TestStatusMap(unittest.TestCase): response_args.append(headers) resp_cls = swift.common.swob.status_map[404] resp = resp_cls() - self.assertEquals(resp.status_int, 404) - self.assertEquals(resp.title, 'Not Found') + self.assertEqual(resp.status_int, 404) + self.assertEqual(resp.title, 'Not Found') body = ''.join(resp({}, start_response)) self.assertTrue('The resource could not be found.' in body) - self.assertEquals(response_args[0], '404 Not Found') + self.assertEqual(response_args[0], '404 Not Found') headers = dict(response_args[1]) - self.assertEquals(headers['Content-Type'], 'text/html; charset=UTF-8') + self.assertEqual(headers['Content-Type'], 'text/html; charset=UTF-8') self.assertTrue(int(headers['Content-Length']) > 0) @@ -1036,7 +1036,7 @@ class TestResponse(unittest.TestCase): resp = self._get_response() resp.location = 'something' - self.assertEquals(resp.location, 'something') + self.assertEqual(resp.location, 'something') self.assertTrue('Location' in resp.headers) resp.location = None self.assertTrue('Location' not in resp.headers) @@ -1049,12 +1049,12 @@ class TestResponse(unittest.TestCase): def test_empty_body(self): resp = self._get_response() resp.body = '' - self.assertEquals(resp.body, '') + self.assertEqual(resp.body, '') def test_unicode_body(self): resp = self._get_response() resp.body = u'\N{SNOWMAN}' - self.assertEquals(resp.body, u'\N{SNOWMAN}'.encode('utf-8')) + self.assertEqual(resp.body, u'\N{SNOWMAN}'.encode('utf-8')) def test_call_reifies_request_if_necessary(self): """ @@ -1072,7 +1072,7 @@ class TestResponse(unittest.TestCase): resp = swift.common.swob.Response(status=status, headers=dict(headers), app_iter=app_iter) output_iter = resp(req.environ, lambda *_: None) - self.assertEquals(list(output_iter), ['']) + self.assertEqual(list(output_iter), ['']) def test_call_preserves_closeability(self): def test_app(environ, start_response): @@ -1099,7 +1099,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'http://somehost/something') + self.assertEqual(resp.location, 'http://somehost/something') req = swift.common.swob.Request.blank( '/', environ={'HTTP_HOST': 'somehost:80'}) @@ -1107,7 +1107,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'http://somehost/something') + self.assertEqual(resp.location, 'http://somehost/something') req = swift.common.swob.Request.blank( '/', environ={'HTTP_HOST': 'somehost:443', @@ -1116,7 +1116,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'http://somehost:443/something') + self.assertEqual(resp.location, 'http://somehost:443/something') req = swift.common.swob.Request.blank( '/', environ={'HTTP_HOST': 'somehost:443', @@ -1125,7 +1125,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'https://somehost/something') + self.assertEqual(resp.location, 'https://somehost/something') def test_location_rewrite_no_host(self): def start_response(env, headers): @@ -1137,7 +1137,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'http://local/something') + self.assertEqual(resp.location, 'http://local/something') req = swift.common.swob.Request.blank( '/', environ={'SERVER_NAME': 'local', 'SERVER_PORT': 81}) @@ -1146,7 +1146,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'http://local:81/something') + self.assertEqual(resp.location, 'http://local:81/something') def test_location_no_rewrite(self): def start_response(env, headers): @@ -1157,7 +1157,7 @@ class TestResponse(unittest.TestCase): resp.location = 'http://www.google.com/' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, 'http://www.google.com/') + self.assertEqual(resp.location, 'http://www.google.com/') def test_location_no_rewrite_when_told_not_to(self): def start_response(env, headers): @@ -1170,7 +1170,7 @@ class TestResponse(unittest.TestCase): resp.location = '/something' # read response ''.join(resp(req.environ, start_response)) - self.assertEquals(resp.location, '/something') + self.assertEqual(resp.location, '/something') def test_app_iter(self): def start_response(env, headers): @@ -1178,7 +1178,7 @@ class TestResponse(unittest.TestCase): resp = self._get_response() resp.app_iter = ['a', 'b', 'c'] body = ''.join(resp({}, start_response)) - self.assertEquals(body, 'abc') + self.assertEqual(body, 'abc') def test_multi_ranges_wo_iter_ranges(self): def test_app(environ, start_response): @@ -1195,7 +1195,7 @@ class TestResponse(unittest.TestCase): # read response ''.join(resp._response_iter(resp.app_iter, '')) - self.assertEquals(resp.status, '200 OK') + self.assertEqual(resp.status, '200 OK') self.assertEqual(10, resp.content_length) def test_single_range_wo_iter_range(self): @@ -1213,7 +1213,7 @@ class TestResponse(unittest.TestCase): # read response ''.join(resp._response_iter(resp.app_iter, '')) - self.assertEquals(resp.status, '200 OK') + self.assertEqual(resp.status, '200 OK') self.assertEqual(10, resp.content_length) def test_multi_range_body(self): @@ -1297,9 +1297,9 @@ class TestResponse(unittest.TestCase): body='1234567890', request=req, conditional_response=True) body = ''.join(resp([], start_response)) - self.assertEquals(body, '234') - self.assertEquals(resp.content_range, 'bytes 1-3/10') - self.assertEquals(resp.status, '206 Partial Content') + self.assertEqual(body, '234') + self.assertEqual(resp.content_range, 'bytes 1-3/10') + self.assertEqual(resp.status, '206 Partial Content') # syntactically valid, but does not make sense, so returning 416 # in next couple of cases. @@ -1308,17 +1308,17 @@ class TestResponse(unittest.TestCase): resp = req.get_response(test_app) resp.conditional_response = True body = ''.join(resp([], start_response)) - self.assertEquals(body, '') - self.assertEquals(resp.content_length, 0) - self.assertEquals(resp.status, '416 Requested Range Not Satisfiable') + self.assertEqual(body, '') + self.assertEqual(resp.content_length, 0) + self.assertEqual(resp.status, '416 Requested Range Not Satisfiable') resp = swift.common.swob.Response( body='1234567890', request=req, conditional_response=True) body = ''.join(resp([], start_response)) - self.assertEquals(body, '') - self.assertEquals(resp.content_length, 0) - self.assertEquals(resp.status, '416 Requested Range Not Satisfiable') + self.assertEqual(body, '') + self.assertEqual(resp.content_length, 0) + self.assertEqual(resp.status, '416 Requested Range Not Satisfiable') # Syntactically-invalid Range headers "MUST" be ignored req = swift.common.swob.Request.blank( @@ -1326,41 +1326,41 @@ class TestResponse(unittest.TestCase): resp = req.get_response(test_app) resp.conditional_response = True body = ''.join(resp([], start_response)) - self.assertEquals(body, '1234567890') - self.assertEquals(resp.status, '200 OK') + self.assertEqual(body, '1234567890') + self.assertEqual(resp.status, '200 OK') resp = swift.common.swob.Response( body='1234567890', request=req, conditional_response=True) body = ''.join(resp([], start_response)) - self.assertEquals(body, '1234567890') - self.assertEquals(resp.status, '200 OK') + self.assertEqual(body, '1234567890') + self.assertEqual(resp.status, '200 OK') def test_content_type(self): resp = self._get_response() resp.content_type = 'text/plain; charset=utf8' - self.assertEquals(resp.content_type, 'text/plain') + self.assertEqual(resp.content_type, 'text/plain') def test_charset(self): resp = self._get_response() resp.content_type = 'text/plain; charset=utf8' - self.assertEquals(resp.charset, 'utf8') + self.assertEqual(resp.charset, 'utf8') resp.charset = 'utf16' - self.assertEquals(resp.charset, 'utf16') + self.assertEqual(resp.charset, 'utf16') def test_charset_content_type(self): resp = swift.common.swob.Response( content_type='text/plain', charset='utf-8') - self.assertEquals(resp.charset, 'utf-8') + self.assertEqual(resp.charset, 'utf-8') resp = swift.common.swob.Response( charset='utf-8', content_type='text/plain') - self.assertEquals(resp.charset, 'utf-8') + self.assertEqual(resp.charset, 'utf-8') def test_etag(self): resp = self._get_response() resp.etag = 'hi' - self.assertEquals(resp.headers['Etag'], '"hi"') - self.assertEquals(resp.etag, 'hi') + self.assertEqual(resp.headers['Etag'], '"hi"') + self.assertEqual(resp.etag, 'hi') self.assertTrue('etag' in resp.headers) resp.etag = None @@ -1373,7 +1373,7 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '1234' del env['HTTP_HOST'] - self.assertEquals(resp.host_url, 'http://bob:1234') + self.assertEqual(resp.host_url, 'http://bob:1234') def test_host_url_default_port_squelched(self): resp = self._get_response() @@ -1382,7 +1382,7 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '80' del env['HTTP_HOST'] - self.assertEquals(resp.host_url, 'http://bob') + self.assertEqual(resp.host_url, 'http://bob') def test_host_url_https(self): resp = self._get_response() @@ -1391,7 +1391,7 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '1234' del env['HTTP_HOST'] - self.assertEquals(resp.host_url, 'https://bob:1234') + self.assertEqual(resp.host_url, 'https://bob:1234') def test_host_url_https_port_squelched(self): resp = self._get_response() @@ -1400,7 +1400,7 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '443' del env['HTTP_HOST'] - self.assertEquals(resp.host_url, 'https://bob') + self.assertEqual(resp.host_url, 'https://bob') def test_host_url_host_override(self): resp = self._get_response() @@ -1409,7 +1409,7 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '1234' env['HTTP_HOST'] = 'someother' - self.assertEquals(resp.host_url, 'http://someother') + self.assertEqual(resp.host_url, 'http://someother') def test_host_url_host_port_override(self): resp = self._get_response() @@ -1418,7 +1418,7 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '1234' env['HTTP_HOST'] = 'someother:5678' - self.assertEquals(resp.host_url, 'http://someother:5678') + self.assertEqual(resp.host_url, 'http://someother:5678') def test_host_url_host_https(self): resp = self._get_response() @@ -1427,18 +1427,18 @@ class TestResponse(unittest.TestCase): env['SERVER_NAME'] = 'bob' env['SERVER_PORT'] = '1234' env['HTTP_HOST'] = 'someother:5678' - self.assertEquals(resp.host_url, 'https://someother:5678') + self.assertEqual(resp.host_url, 'https://someother:5678') def test_507(self): resp = swift.common.swob.HTTPInsufficientStorage() content = ''.join(resp._response_iter(resp.app_iter, resp._body)) - self.assertEquals( + self.assertEqual( content, '

Insufficient Storage

There was not enough space ' 'to save the resource. Drive: unknown

') resp = swift.common.swob.HTTPInsufficientStorage(drive='sda1') content = ''.join(resp._response_iter(resp.app_iter, resp._body)) - self.assertEquals( + self.assertEqual( content, '

Insufficient Storage

There was not enough space ' 'to save the resource. Drive: sda1

') @@ -1447,57 +1447,57 @@ class TestResponse(unittest.TestCase): headers = {'Content-Length': '0'} content = 'foo' resp = swift.common.swob.HTTPOk(body=content, headers=headers) - self.assertEquals(resp.body, content) - self.assertEquals(resp.content_length, len(content)) + self.assertEqual(resp.body, content) + self.assertEqual(resp.content_length, len(content)) def test_init_with_body_headers_app_iter(self): # body exists but no headers and no app_iter body = 'ok' resp = swift.common.swob.Response(body=body) - self.assertEquals(resp.body, body) - self.assertEquals(resp.content_length, len(body)) + self.assertEqual(resp.body, body) + self.assertEqual(resp.content_length, len(body)) # body and headers with 0 content_length exist but no app_iter body = 'ok' resp = swift.common.swob.Response( body=body, headers={'Content-Length': '0'}) - self.assertEquals(resp.body, body) - self.assertEquals(resp.content_length, len(body)) + self.assertEqual(resp.body, body) + self.assertEqual(resp.content_length, len(body)) # body and headers with content_length exist but no app_iter body = 'ok' resp = swift.common.swob.Response( body=body, headers={'Content-Length': '5'}) - self.assertEquals(resp.body, body) - self.assertEquals(resp.content_length, len(body)) + self.assertEqual(resp.body, body) + self.assertEqual(resp.content_length, len(body)) # body and headers with no content_length exist but no app_iter body = 'ok' resp = swift.common.swob.Response(body=body, headers={}) - self.assertEquals(resp.body, body) - self.assertEquals(resp.content_length, len(body)) + self.assertEqual(resp.body, body) + self.assertEqual(resp.content_length, len(body)) # body, headers with content_length and app_iter exist resp = swift.common.swob.Response( body='ok', headers={'Content-Length': '5'}, app_iter=iter([])) - self.assertEquals(resp.content_length, 5) - self.assertEquals(resp.body, '') + self.assertEqual(resp.content_length, 5) + self.assertEqual(resp.body, '') # headers with content_length and app_iter exist but no body resp = swift.common.swob.Response( headers={'Content-Length': '5'}, app_iter=iter([])) - self.assertEquals(resp.content_length, 5) - self.assertEquals(resp.body, '') + self.assertEqual(resp.content_length, 5) + self.assertEqual(resp.body, '') # app_iter exists but no body and headers resp = swift.common.swob.Response(app_iter=iter([])) - self.assertEquals(resp.content_length, None) - self.assertEquals(resp.body, '') + self.assertEqual(resp.content_length, None) + self.assertEqual(resp.body, '') class TestUTC(unittest.TestCase): def test_tzname(self): - self.assertEquals(swift.common.swob.UTC.tzname(None), 'UTC') + self.assertEqual(swift.common.swob.UTC.tzname(None), 'UTC') class TestConditionalIfNoneMatch(unittest.TestCase): @@ -1515,8 +1515,8 @@ class TestConditionalIfNoneMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 304) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 304) + self.assertEqual(body, '') def test_quoted_simple_match(self): # double quotes don't matter @@ -1525,8 +1525,8 @@ class TestConditionalIfNoneMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 304) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 304) + self.assertEqual(body, '') def test_list_match(self): # it works with lists of etags to match @@ -1535,8 +1535,8 @@ class TestConditionalIfNoneMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 304) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 304) + self.assertEqual(body, '') def test_list_no_match(self): # no matches --> whatever the original status was @@ -1545,8 +1545,8 @@ class TestConditionalIfNoneMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_match_star(self): # "*" means match anything; see RFC 2616 section 14.24 @@ -1555,8 +1555,8 @@ class TestConditionalIfNoneMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 304) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 304) + self.assertEqual(body, '') class TestConditionalIfMatch(unittest.TestCase): @@ -1574,8 +1574,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_simple_conditional_etag_match(self): # if etag matches, proceed as normal @@ -1585,8 +1585,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp.conditional_response = True resp._conditional_etag = 'not-the-etag' body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_quoted_simple_match(self): # double quotes or not, doesn't matter @@ -1595,8 +1595,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_no_match(self): # no match --> 412 @@ -1605,8 +1605,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 412) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 412) + self.assertEqual(body, '') def test_simple_conditional_etag_no_match(self): req = swift.common.swob.Request.blank( @@ -1615,8 +1615,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp.conditional_response = True resp._conditional_etag = 'not-the-etag' body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 412) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 412) + self.assertEqual(body, '') def test_match_star(self): # "*" means match anything; see RFC 2616 section 14.24 @@ -1625,8 +1625,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_match_star_on_404(self): @@ -1639,8 +1639,8 @@ class TestConditionalIfMatch(unittest.TestCase): resp = req.get_response(fake_app_404) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 412) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 412) + self.assertEqual(body, '') class TestConditionalIfModifiedSince(unittest.TestCase): @@ -1657,8 +1657,8 @@ class TestConditionalIfModifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_before(self): req = swift.common.swob.Request.blank( @@ -1667,8 +1667,8 @@ class TestConditionalIfModifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_same(self): req = swift.common.swob.Request.blank( @@ -1677,8 +1677,8 @@ class TestConditionalIfModifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 304) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 304) + self.assertEqual(body, '') def test_greater(self): req = swift.common.swob.Request.blank( @@ -1687,8 +1687,8 @@ class TestConditionalIfModifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 304) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 304) + self.assertEqual(body, '') def test_out_of_range_is_ignored(self): # All that datetime gives us is a ValueError or OverflowError when @@ -1707,8 +1707,8 @@ class TestConditionalIfModifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') class TestConditionalIfUnmodifiedSince(unittest.TestCase): @@ -1725,8 +1725,8 @@ class TestConditionalIfUnmodifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_before(self): req = swift.common.swob.Request.blank( @@ -1735,8 +1735,8 @@ class TestConditionalIfUnmodifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 412) - self.assertEquals(body, '') + self.assertEqual(resp.status_int, 412) + self.assertEqual(body, '') def test_same(self): req = swift.common.swob.Request.blank( @@ -1745,8 +1745,8 @@ class TestConditionalIfUnmodifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_greater(self): req = swift.common.swob.Request.blank( @@ -1755,8 +1755,8 @@ class TestConditionalIfUnmodifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') def test_out_of_range_is_ignored(self): # All that datetime gives us is a ValueError or OverflowError when @@ -1775,8 +1775,8 @@ class TestConditionalIfUnmodifiedSince(unittest.TestCase): resp = req.get_response(self.fake_app) resp.conditional_response = True body = ''.join(resp(req.environ, self.fake_start_response)) - self.assertEquals(resp.status_int, 200) - self.assertEquals(body, 'hi') + self.assertEqual(resp.status_int, 200) + self.assertEqual(body, 'hi') if __name__ == '__main__': diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 02f8191fdc..aca4e93d4d 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -861,60 +861,60 @@ class TestUtils(unittest.TestCase): def test_normalize_timestamp(self): # Test swift.common.utils.normalize_timestamp - self.assertEquals(utils.normalize_timestamp('1253327593.48174'), - "1253327593.48174") - self.assertEquals(utils.normalize_timestamp(1253327593.48174), - "1253327593.48174") - self.assertEquals(utils.normalize_timestamp('1253327593.48'), - "1253327593.48000") - self.assertEquals(utils.normalize_timestamp(1253327593.48), - "1253327593.48000") - self.assertEquals(utils.normalize_timestamp('253327593.48'), - "0253327593.48000") - self.assertEquals(utils.normalize_timestamp(253327593.48), - "0253327593.48000") - self.assertEquals(utils.normalize_timestamp('1253327593'), - "1253327593.00000") - self.assertEquals(utils.normalize_timestamp(1253327593), - "1253327593.00000") + self.assertEqual(utils.normalize_timestamp('1253327593.48174'), + "1253327593.48174") + self.assertEqual(utils.normalize_timestamp(1253327593.48174), + "1253327593.48174") + self.assertEqual(utils.normalize_timestamp('1253327593.48'), + "1253327593.48000") + self.assertEqual(utils.normalize_timestamp(1253327593.48), + "1253327593.48000") + self.assertEqual(utils.normalize_timestamp('253327593.48'), + "0253327593.48000") + self.assertEqual(utils.normalize_timestamp(253327593.48), + "0253327593.48000") + self.assertEqual(utils.normalize_timestamp('1253327593'), + "1253327593.00000") + self.assertEqual(utils.normalize_timestamp(1253327593), + "1253327593.00000") self.assertRaises(ValueError, utils.normalize_timestamp, '') self.assertRaises(ValueError, utils.normalize_timestamp, 'abc') def test_normalize_delete_at_timestamp(self): - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp(1253327593), '1253327593') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp(1253327593.67890), '1253327593') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp('1253327593'), '1253327593') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp('1253327593.67890'), '1253327593') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp(-1253327593), '0000000000') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp(-1253327593.67890), '0000000000') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp('-1253327593'), '0000000000') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp('-1253327593.67890'), '0000000000') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp(71253327593), '9999999999') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp(71253327593.67890), '9999999999') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp('71253327593'), '9999999999') - self.assertEquals( + self.assertEqual( utils.normalize_delete_at_timestamp('71253327593.67890'), '9999999999') self.assertRaises(ValueError, utils.normalize_timestamp, '') @@ -971,12 +971,12 @@ class TestUtils(unittest.TestCase): count = len(lines) - 1 for line in utils.backward(f, blocksize): - self.assertEquals(line, lines[count].split('\n')[0]) + self.assertEqual(line, lines[count].split('\n')[0]) count -= 1 # Empty file case with TemporaryFile('r') as f: - self.assertEquals([], list(utils.backward(f))) + self.assertEqual([], list(utils.backward(f))) def test_mkdirs(self): testdir_base = mkdtemp() @@ -1009,9 +1009,9 @@ class TestUtils(unittest.TestCase): self.assertRaises(ValueError, utils.split_path, '') self.assertRaises(ValueError, utils.split_path, '/') self.assertRaises(ValueError, utils.split_path, '//') - self.assertEquals(utils.split_path('/a'), ['a']) + self.assertEqual(utils.split_path('/a'), ['a']) self.assertRaises(ValueError, utils.split_path, '//a') - self.assertEquals(utils.split_path('/a/'), ['a']) + self.assertEqual(utils.split_path('/a/'), ['a']) self.assertRaises(ValueError, utils.split_path, '/a/c') self.assertRaises(ValueError, utils.split_path, '//c') self.assertRaises(ValueError, utils.split_path, '/a/c/') @@ -1019,24 +1019,24 @@ class TestUtils(unittest.TestCase): self.assertRaises(ValueError, utils.split_path, '/a', 2) self.assertRaises(ValueError, utils.split_path, '/a', 2, 3) self.assertRaises(ValueError, utils.split_path, '/a', 2, 3, True) - self.assertEquals(utils.split_path('/a/c', 2), ['a', 'c']) - self.assertEquals(utils.split_path('/a/c/o', 3), ['a', 'c', 'o']) + self.assertEqual(utils.split_path('/a/c', 2), ['a', 'c']) + self.assertEqual(utils.split_path('/a/c/o', 3), ['a', 'c', 'o']) self.assertRaises(ValueError, utils.split_path, '/a/c/o/r', 3, 3) - self.assertEquals(utils.split_path('/a/c/o/r', 3, 3, True), - ['a', 'c', 'o/r']) - self.assertEquals(utils.split_path('/a/c', 2, 3, True), - ['a', 'c', None]) + self.assertEqual(utils.split_path('/a/c/o/r', 3, 3, True), + ['a', 'c', 'o/r']) + self.assertEqual(utils.split_path('/a/c', 2, 3, True), + ['a', 'c', None]) self.assertRaises(ValueError, utils.split_path, '/a', 5, 4) - self.assertEquals(utils.split_path('/a/c/', 2), ['a', 'c']) - self.assertEquals(utils.split_path('/a/c/', 2, 3), ['a', 'c', '']) + self.assertEqual(utils.split_path('/a/c/', 2), ['a', 'c']) + self.assertEqual(utils.split_path('/a/c/', 2, 3), ['a', 'c', '']) try: utils.split_path('o\nn e', 2) except ValueError as err: - self.assertEquals(str(err), 'Invalid path: o%0An%20e') + self.assertEqual(str(err), 'Invalid path: o%0An%20e') try: utils.split_path('o\nn e', 2, 3, True) except ValueError as err: - self.assertEquals(str(err), 'Invalid path: o%0An%20e') + self.assertEqual(str(err), 'Invalid path: o%0An%20e') def test_validate_device_partition(self): # Test swift.common.utils.validate_device_partition @@ -1062,18 +1062,18 @@ class TestUtils(unittest.TestCase): try: utils.validate_device_partition('o\nn e', 'foo') except ValueError as err: - self.assertEquals(str(err), 'Invalid device: o%0An%20e') + self.assertEqual(str(err), 'Invalid device: o%0An%20e') try: utils.validate_device_partition('foo', 'o\nn e') except ValueError as err: - self.assertEquals(str(err), 'Invalid partition: o%0An%20e') + self.assertEqual(str(err), 'Invalid partition: o%0An%20e') def test_NullLogger(self): # Test swift.common.utils.NullLogger sio = StringIO() nl = utils.NullLogger() nl.write('test') - self.assertEquals(sio.getvalue(), '') + self.assertEqual(sio.getvalue(), '') def test_LoggerFileObject(self): orig_stdout = sys.stdout @@ -1086,34 +1086,34 @@ class TestUtils(unittest.TestCase): lfo_stderr = utils.LoggerFileObject(logger) lfo_stderr = utils.LoggerFileObject(logger, 'STDERR') print('test1') - self.assertEquals(sio.getvalue(), '') + self.assertEqual(sio.getvalue(), '') sys.stdout = lfo_stdout print('test2') - self.assertEquals(sio.getvalue(), 'STDOUT: test2\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\n') sys.stderr = lfo_stderr print('test4', file=sys.stderr) - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n') sys.stdout = orig_stdout print('test5') - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n') print('test6', file=sys.stderr) - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' - 'STDERR: test6\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' + 'STDERR: test6\n') sys.stderr = orig_stderr print('test8') - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' - 'STDERR: test6\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' + 'STDERR: test6\n') lfo_stdout.writelines(['a', 'b', 'c']) - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' - 'STDERR: test6\nSTDOUT: a#012b#012c\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' + 'STDERR: test6\nSTDOUT: a#012b#012c\n') lfo_stdout.close() lfo_stderr.close() lfo_stdout.write('d') - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' - 'STDERR: test6\nSTDOUT: a#012b#012c\nSTDOUT: d\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' + 'STDERR: test6\nSTDOUT: a#012b#012c\nSTDOUT: d\n') lfo_stdout.flush() - self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' - 'STDERR: test6\nSTDOUT: a#012b#012c\nSTDOUT: d\n') + self.assertEqual(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n' + 'STDERR: test6\nSTDOUT: a#012b#012c\nSTDOUT: d\n') for lfo in (lfo_stdout, lfo_stderr): got_exc = False try: @@ -1140,26 +1140,26 @@ class TestUtils(unittest.TestCase): with NamedTemporaryFile() as f: conf_file = f.name conf, options = utils.parse_options(test_args=[conf_file]) - self.assertEquals(conf, conf_file) + self.assertEqual(conf, conf_file) # assert defaults - self.assertEquals(options['verbose'], False) + self.assertEqual(options['verbose'], False) self.assertTrue('once' not in options) # assert verbose as option conf, options = utils.parse_options(test_args=[conf_file, '-v']) - self.assertEquals(options['verbose'], True) + self.assertEqual(options['verbose'], True) # check once option conf, options = utils.parse_options(test_args=[conf_file], once=True) - self.assertEquals(options['once'], False) + self.assertEqual(options['once'], False) test_args = [conf_file, '--once'] conf, options = utils.parse_options(test_args=test_args, once=True) - self.assertEquals(options['once'], True) + self.assertEqual(options['once'], True) # check options as arg parsing test_args = [conf_file, 'once', 'plugin_name', 'verbose'] conf, options = utils.parse_options(test_args=test_args, once=True) - self.assertEquals(options['verbose'], True) - self.assertEquals(options['once'], True) - self.assertEquals(options['extra_args'], ['plugin_name']) + self.assertEqual(options['verbose'], True) + self.assertEqual(options['once'], True) + self.assertEqual(options['extra_args'], ['plugin_name']) def test_parse_options_errors(self): orig_stdout = sys.stdout @@ -1193,7 +1193,7 @@ class TestUtils(unittest.TestCase): fd = open(testcache_file) file_dict = json.loads(fd.readline()) fd.close() - self.assertEquals(submit_dict, file_dict) + self.assertEqual(submit_dict, file_dict) # Use a nested entry submit_dict = {'key1': {'key2': {'value1': 1, 'value2': 2}}} result_dict = {'key1': {'key2': {'value1': 1, 'value2': 2}, @@ -1202,7 +1202,7 @@ class TestUtils(unittest.TestCase): fd = open(testcache_file) file_dict = json.loads(fd.readline()) fd.close() - self.assertEquals(result_dict, file_dict) + self.assertEqual(result_dict, file_dict) finally: rmtree(testdir_base) @@ -1212,28 +1212,28 @@ class TestUtils(unittest.TestCase): logger.addHandler(logging.StreamHandler(sio)) logger = utils.get_logger(None, 'server', log_route='server') logger.warn('test1') - self.assertEquals(sio.getvalue(), 'test1\n') + self.assertEqual(sio.getvalue(), 'test1\n') logger.debug('test2') - self.assertEquals(sio.getvalue(), 'test1\n') + self.assertEqual(sio.getvalue(), 'test1\n') logger = utils.get_logger({'log_level': 'DEBUG'}, 'server', log_route='server') logger.debug('test3') - self.assertEquals(sio.getvalue(), 'test1\ntest3\n') + self.assertEqual(sio.getvalue(), 'test1\ntest3\n') # Doesn't really test that the log facility is truly being used all the # way to syslog; but exercises the code. logger = utils.get_logger({'log_facility': 'LOG_LOCAL3'}, 'server', log_route='server') logger.warn('test4') - self.assertEquals(sio.getvalue(), - 'test1\ntest3\ntest4\n') + self.assertEqual(sio.getvalue(), + 'test1\ntest3\ntest4\n') # make sure debug doesn't log by default logger.debug('test5') - self.assertEquals(sio.getvalue(), - 'test1\ntest3\ntest4\n') + self.assertEqual(sio.getvalue(), + 'test1\ntest3\ntest4\n') # make sure notice lvl logs by default logger.notice('test6') - self.assertEquals(sio.getvalue(), - 'test1\ntest3\ntest4\ntest6\n') + self.assertEqual(sio.getvalue(), + 'test1\ntest3\ntest4\ntest6\n') def test_get_logger_sysloghandler_plumbing(self): orig_sysloghandler = utils.SysLogHandler @@ -1260,14 +1260,14 @@ class TestUtils(unittest.TestCase): # a fallback to UDP. expected_args.append( ((), {'facility': orig_sysloghandler.LOG_LOCAL3})) - self.assertEquals(expected_args, syslog_handler_args) + self.assertEqual(expected_args, syslog_handler_args) syslog_handler_args = [] utils.get_logger({ 'log_facility': 'LOG_LOCAL3', 'log_address': '/foo/bar', }, 'server', log_route='server') - self.assertEquals([ + self.assertEqual([ ((), {'address': '/foo/bar', 'facility': orig_sysloghandler.LOG_LOCAL3}), # Second call is because /foo/bar didn't exist (and wasn't a @@ -1280,7 +1280,7 @@ class TestUtils(unittest.TestCase): utils.get_logger({ 'log_udp_host': 'syslog.funtimes.com', }, 'server', log_route='server') - self.assertEquals([ + self.assertEqual([ ((), {'address': ('syslog.funtimes.com', logging.handlers.SYSLOG_UDP_PORT), 'facility': orig_sysloghandler.LOG_LOCAL0})], @@ -1292,7 +1292,7 @@ class TestUtils(unittest.TestCase): 'log_udp_host': 'syslog.funtimes.com', 'log_udp_port': '2123', }, 'server', log_route='server') - self.assertEquals([ + self.assertEqual([ ((), {'address': ('syslog.funtimes.com', 2123), 'facility': orig_sysloghandler.LOG_LOCAL0})], syslog_handler_args) @@ -1319,14 +1319,14 @@ class TestUtils(unittest.TestCase): logger.exception('blah') try: # establish base case - self.assertEquals(strip_value(sio), '') + self.assertEqual(strip_value(sio), '') logger.info('test') - self.assertEquals(strip_value(sio), 'test\n') - self.assertEquals(strip_value(sio), '') + self.assertEqual(strip_value(sio), 'test\n') + self.assertEqual(strip_value(sio), '') logger.info('test') logger.info('test') - self.assertEquals(strip_value(sio), 'test\ntest\n') - self.assertEquals(strip_value(sio), '') + self.assertEqual(strip_value(sio), 'test\ntest\n') + self.assertEqual(strip_value(sio), '') # test OSError for en in (errno.EIO, errno.ENOSPC): @@ -1471,15 +1471,15 @@ class TestUtils(unittest.TestCase): self.assertTrue('txn' in log_msg) self.assertTrue('12345' in log_msg) # test no txn on info message - self.assertEquals(logger.txn_id, '12345') + self.assertEqual(logger.txn_id, '12345') logger.info('test') log_msg = strip_value(sio) self.assertTrue('txn' not in log_msg) self.assertTrue('12345' not in log_msg) # test txn already in message - self.assertEquals(logger.txn_id, '12345') + self.assertEqual(logger.txn_id, '12345') logger.warn('test 12345 test') - self.assertEquals(strip_value(sio), 'test 12345 test\n') + self.assertEqual(strip_value(sio), 'test 12345 test\n') # Test multi line collapsing logger.error('my\nerror\nmessage') log_msg = strip_value(sio) @@ -1497,21 +1497,21 @@ class TestUtils(unittest.TestCase): self.assertTrue('client_ip' in log_msg) self.assertTrue('1.2.3.4' in log_msg) # test no client_ip on info message - self.assertEquals(logger.client_ip, '1.2.3.4') + self.assertEqual(logger.client_ip, '1.2.3.4') logger.info('test') log_msg = strip_value(sio) self.assertTrue('client_ip' not in log_msg) self.assertTrue('1.2.3.4' not in log_msg) # test client_ip (and txn) already in message - self.assertEquals(logger.client_ip, '1.2.3.4') + self.assertEqual(logger.client_ip, '1.2.3.4') logger.warn('test 1.2.3.4 test 12345') - self.assertEquals(strip_value(sio), 'test 1.2.3.4 test 12345\n') + self.assertEqual(strip_value(sio), 'test 1.2.3.4 test 12345\n') finally: logger.logger.removeHandler(handler) def test_storage_directory(self): - self.assertEquals(utils.storage_directory('objects', '1', 'ABCDEF'), - 'objects/1/DEF/ABCDEF') + self.assertEqual(utils.storage_directory('objects', '1', 'ABCDEF'), + 'objects/1/DEF/ABCDEF') def test_expand_ipv6(self): expanded_ipv6 = "fe80::204:61ff:fe9d:f156" @@ -1549,7 +1549,7 @@ class TestUtils(unittest.TestCase): with nested( patch('netifaces.interfaces', my_interfaces), patch('netifaces.ifaddresses', my_ifaddress_error)): - self.assertEquals(utils.whataremyips(), []) + self.assertEqual(utils.whataremyips(), []) def test_whataremyips_ipv6(self): test_ipv6_address = '2001:6b0:dead:beef:2::32' @@ -1566,8 +1566,8 @@ class TestUtils(unittest.TestCase): patch('netifaces.interfaces', my_ipv6_interfaces), patch('netifaces.ifaddresses', my_ipv6_ifaddresses)): myips = utils.whataremyips() - self.assertEquals(len(myips), 1) - self.assertEquals(myips[0], test_ipv6_address) + self.assertEqual(len(myips), 1) + self.assertEqual(myips[0], test_ipv6_address) def test_hash_path(self): _prefix = utils.HASH_PATH_PREFIX @@ -1575,21 +1575,21 @@ class TestUtils(unittest.TestCase): # Yes, these tests are deliberately very fragile. We want to make sure # that if someones changes the results hash_path produces, they know it try: - self.assertEquals(utils.hash_path('a'), - '1c84525acb02107ea475dcd3d09c2c58') - self.assertEquals(utils.hash_path('a', 'c'), - '33379ecb053aa5c9e356c68997cbb59e') - self.assertEquals(utils.hash_path('a', 'c', 'o'), - '06fbf0b514e5199dfc4e00f42eb5ea83') - self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=False), - '06fbf0b514e5199dfc4e00f42eb5ea83') - self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=True), - '\x06\xfb\xf0\xb5\x14\xe5\x19\x9d\xfcN' - '\x00\xf4.\xb5\xea\x83') + self.assertEqual(utils.hash_path('a'), + '1c84525acb02107ea475dcd3d09c2c58') + self.assertEqual(utils.hash_path('a', 'c'), + '33379ecb053aa5c9e356c68997cbb59e') + self.assertEqual(utils.hash_path('a', 'c', 'o'), + '06fbf0b514e5199dfc4e00f42eb5ea83') + self.assertEqual(utils.hash_path('a', 'c', 'o', raw_digest=False), + '06fbf0b514e5199dfc4e00f42eb5ea83') + self.assertEqual(utils.hash_path('a', 'c', 'o', raw_digest=True), + '\x06\xfb\xf0\xb5\x14\xe5\x19\x9d\xfcN' + '\x00\xf4.\xb5\xea\x83') self.assertRaises(ValueError, utils.hash_path, 'a', object='o') utils.HASH_PATH_PREFIX = 'abcdef' - self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=False), - '363f9b535bfb7d17a43a46a358afca0e') + self.assertEqual(utils.hash_path('a', 'c', 'o', raw_digest=False), + '363f9b535bfb7d17a43a46a358afca0e') finally: utils.HASH_PATH_PREFIX = _prefix @@ -1622,28 +1622,28 @@ log_name = yarr''' 'log_name': None, 'section1': {'foo': 'bar'}, 'section2': {'log_name': 'yarr'}} - self.assertEquals(result, expected) + self.assertEqual(result, expected) conffile = conf_object_maker() result = utils.readconf(conffile, 'section1') expected = {'__file__': conffile, 'log_name': 'section1', 'foo': 'bar'} - self.assertEquals(result, expected) + self.assertEqual(result, expected) conffile = conf_object_maker() result = utils.readconf(conffile, 'section2').get('log_name') expected = 'yarr' - self.assertEquals(result, expected) + self.assertEqual(result, expected) conffile = conf_object_maker() result = utils.readconf(conffile, 'section1', log_name='foo').get('log_name') expected = 'foo' - self.assertEquals(result, expected) + self.assertEqual(result, expected) conffile = conf_object_maker() result = utils.readconf(conffile, 'section1', defaults={'bar': 'baz'}) expected = {'__file__': conffile, 'log_name': 'section1', 'foo': 'bar', 'bar': 'baz'} - self.assertEquals(result, expected) + self.assertEqual(result, expected) self.assertRaises(SystemExit, utils.readconf, temppath, 'section3') os.unlink(temppath) self.assertRaises(SystemExit, utils.readconf, temppath) @@ -1668,7 +1668,7 @@ log_name = %(yarr)s''' 'log_name': None, 'section1': {'foo': 'bar'}, 'section2': {'log_name': '%(yarr)s'}} - self.assertEquals(result, expected) + self.assertEqual(result, expected) os.unlink(temppath) self.assertRaises(SystemExit, utils.readconf, temppath) @@ -1719,7 +1719,7 @@ log_name = %(yarr)s''' 'name': 'section2', }, } - self.assertEquals(conf, expected) + self.assertEqual(conf, expected) def test_readconf_dir_ignores_hidden_and_nondotconf_files(self): config_dir = { @@ -1748,7 +1748,7 @@ log_name = %(yarr)s''' 'port': '8080', }, } - self.assertEquals(conf, expected) + self.assertEqual(conf, expected) def test_drop_privileges(self): user = getuser() @@ -1761,11 +1761,11 @@ log_name = %(yarr)s''' for func in required_func_calls: self.assertTrue(utils.os.called_funcs[func]) import pwd - self.assertEquals(pwd.getpwnam(user)[5], utils.os.environ['HOME']) + self.assertEqual(pwd.getpwnam(user)[5], utils.os.environ['HOME']) groups = [g.gr_gid for g in grp.getgrall() if user in g.gr_mem] groups.append(pwd.getpwnam(user).pw_gid) - self.assertEquals(set(groups), set(os.getgroups())) + self.assertEqual(set(groups), set(os.getgroups())) # reset; test same args, OSError trying to get session leader utils.os = MockOs(called_funcs=required_func_calls, @@ -1806,7 +1806,7 @@ log_name = %(yarr)s''' # basic test utils.capture_stdio(logger) self.assertTrue(utils.sys.excepthook is not None) - self.assertEquals(utils.os.closed_fds, utils.sys.stdio_fds) + self.assertEqual(utils.os.closed_fds, utils.sys.stdio_fds) self.assertTrue( isinstance(utils.sys.stdout, utils.LoggerFileObject)) self.assertTrue( @@ -1819,7 +1819,7 @@ log_name = %(yarr)s''' # test unable to close stdio utils.capture_stdio(logger) self.assertTrue(utils.sys.excepthook is not None) - self.assertEquals(utils.os.closed_fds, []) + self.assertEqual(utils.os.closed_fds, []) self.assertTrue( isinstance(utils.sys.stdout, utils.LoggerFileObject)) self.assertTrue( @@ -1835,7 +1835,7 @@ log_name = %(yarr)s''' capture_stderr=False) self.assertTrue(utils.sys.excepthook is not None) # when logging to console, stderr remains open - self.assertEquals(utils.os.closed_fds, utils.sys.stdio_fds[:2]) + self.assertEqual(utils.os.closed_fds, utils.sys.stdio_fds[:2]) reset_loggers() # stdio not captured @@ -1858,12 +1858,12 @@ log_name = %(yarr)s''' isinstance(h, logging.StreamHandler)] self.assertTrue(console_handlers) # make sure you can't have two console handlers - self.assertEquals(len(console_handlers), 1) + self.assertEqual(len(console_handlers), 1) old_handler = console_handlers[0] logger = utils.get_logger(None, log_to_console=True) console_handlers = [h for h in logger.logger.handlers if isinstance(h, logging.StreamHandler)] - self.assertEquals(len(console_handlers), 1) + self.assertEqual(len(console_handlers), 1) new_handler = console_handlers[0] self.assertNotEquals(new_handler, old_handler) @@ -1926,7 +1926,7 @@ log_name = %(yarr)s''' running_time = utils.ratelimit_sleep(running_time, 500, incr_by=i) total += i - self.assertEquals(248, total) + self.assertEqual(248, total) self.verify_under_pseudo_time(testfunc, target_runtime_ms=500) @@ -1944,42 +1944,42 @@ log_name = %(yarr)s''' def test_urlparse(self): parsed = utils.urlparse('http://127.0.0.1/') - self.assertEquals(parsed.scheme, 'http') - self.assertEquals(parsed.hostname, '127.0.0.1') - self.assertEquals(parsed.path, '/') + self.assertEqual(parsed.scheme, 'http') + self.assertEqual(parsed.hostname, '127.0.0.1') + self.assertEqual(parsed.path, '/') parsed = utils.urlparse('http://127.0.0.1:8080/') - self.assertEquals(parsed.port, 8080) + self.assertEqual(parsed.port, 8080) parsed = utils.urlparse('https://127.0.0.1/') - self.assertEquals(parsed.scheme, 'https') + self.assertEqual(parsed.scheme, 'https') parsed = utils.urlparse('http://[::1]/') - self.assertEquals(parsed.hostname, '::1') + self.assertEqual(parsed.hostname, '::1') parsed = utils.urlparse('http://[::1]:8080/') - self.assertEquals(parsed.hostname, '::1') - self.assertEquals(parsed.port, 8080) + self.assertEqual(parsed.hostname, '::1') + self.assertEqual(parsed.port, 8080) parsed = utils.urlparse('www.example.com') - self.assertEquals(parsed.hostname, '') + self.assertEqual(parsed.hostname, '') def test_search_tree(self): # file match & ext miss with temptree(['asdf.conf', 'blarg.conf', 'asdf.cfg']) as t: asdf = utils.search_tree(t, 'a*', '.conf') - self.assertEquals(len(asdf), 1) - self.assertEquals(asdf[0], - os.path.join(t, 'asdf.conf')) + self.assertEqual(len(asdf), 1) + self.assertEqual(asdf[0], + os.path.join(t, 'asdf.conf')) # multi-file match & glob miss & sort with temptree(['application.bin', 'apple.bin', 'apropos.bin']) as t: app_bins = utils.search_tree(t, 'app*', 'bin') - self.assertEquals(len(app_bins), 2) - self.assertEquals(app_bins[0], - os.path.join(t, 'apple.bin')) - self.assertEquals(app_bins[1], - os.path.join(t, 'application.bin')) + self.assertEqual(len(app_bins), 2) + self.assertEqual(app_bins[0], + os.path.join(t, 'apple.bin')) + self.assertEqual(app_bins[1], + os.path.join(t, 'application.bin')) # test file in folder & ext miss & glob miss files = ( @@ -1991,9 +1991,9 @@ log_name = %(yarr)s''' ) with temptree(files) as t: sub_ini = utils.search_tree(t, 'sub*', '.ini') - self.assertEquals(len(sub_ini), 1) - self.assertEquals(sub_ini[0], - os.path.join(t, 'sub/file1.ini')) + self.assertEqual(len(sub_ini), 1) + self.assertEqual(sub_ini[0], + os.path.join(t, 'sub/file1.ini')) # test multi-file in folder & sub-folder & ext miss & glob miss files = ( @@ -2006,7 +2006,7 @@ log_name = %(yarr)s''' ) with temptree(files) as t: folder_texts = utils.search_tree(t, 'folder*', '.txt') - self.assertEquals(len(folder_texts), 4) + self.assertEqual(len(folder_texts), 4) f1 = os.path.join(t, 'folder_file.txt') f2 = os.path.join(t, 'folder/1.txt') f3 = os.path.join(t, 'folder/sub/2.txt') @@ -2029,7 +2029,7 @@ log_name = %(yarr)s''' with temptree(files) as t: conf_dirs = utils.search_tree(t, 'object-server', '.conf', dir_ext='conf.d') - self.assertEquals(len(conf_dirs), 4) + self.assertEqual(len(conf_dirs), 4) for i in range(4): conf_dir = os.path.join(t, 'object-server/%d.conf.d' % (i + 1)) self.assertTrue(conf_dir in conf_dirs) @@ -2044,7 +2044,7 @@ log_name = %(yarr)s''' with temptree(files) as t: conf_dirs = utils.search_tree(t, 'proxy-server', 'noauth.conf', dir_ext='noauth.conf.d') - self.assertEquals(len(conf_dirs), 1) + self.assertEqual(len(conf_dirs), 1) conf_dir = conf_dirs[0] expected = os.path.join(t, 'proxy-server/proxy-noauth.conf.d') self.assertEqual(conf_dir, expected) @@ -2057,7 +2057,7 @@ log_name = %(yarr)s''' with temptree(files) as t: pid_files = utils.search_tree(t, 'proxy-server', exts=['noauth.pid', 'noauth.pid.d']) - self.assertEquals(len(pid_files), 1) + self.assertEqual(len(pid_files), 1) pid_file = pid_files[0] expected = os.path.join(t, 'proxy-server/proxy-noauth.pid.d') self.assertEqual(pid_file, expected) @@ -2068,13 +2068,13 @@ log_name = %(yarr)s''' utils.write_file(file_name, 'test') with open(file_name, 'r') as f: contents = f.read() - self.assertEquals(contents, 'test') + self.assertEqual(contents, 'test') # and also subdirs file_name = os.path.join(t, 'subdir/test2') utils.write_file(file_name, 'test2') with open(file_name, 'r') as f: contents = f.read() - self.assertEquals(contents, 'test2') + self.assertEqual(contents, 'test2') # but can't over-write files file_name = os.path.join(t, 'subdir/test2/test3') self.assertRaises(IOError, utils.write_file, file_name, @@ -2084,36 +2084,36 @@ log_name = %(yarr)s''' with temptree([]) as t: file_name = os.path.join(t, 'blah.pid') # assert no raise - self.assertEquals(os.path.exists(file_name), False) - self.assertEquals(utils.remove_file(file_name), None) + self.assertEqual(os.path.exists(file_name), False) + self.assertEqual(utils.remove_file(file_name), None) with open(file_name, 'w') as f: f.write('1') self.assertTrue(os.path.exists(file_name)) - self.assertEquals(utils.remove_file(file_name), None) + self.assertEqual(utils.remove_file(file_name), None) self.assertFalse(os.path.exists(file_name)) def test_human_readable(self): - self.assertEquals(utils.human_readable(0), '0') - self.assertEquals(utils.human_readable(1), '1') - self.assertEquals(utils.human_readable(10), '10') - self.assertEquals(utils.human_readable(100), '100') - self.assertEquals(utils.human_readable(999), '999') - self.assertEquals(utils.human_readable(1024), '1Ki') - self.assertEquals(utils.human_readable(1535), '1Ki') - self.assertEquals(utils.human_readable(1536), '2Ki') - self.assertEquals(utils.human_readable(1047552), '1023Ki') - self.assertEquals(utils.human_readable(1048063), '1023Ki') - self.assertEquals(utils.human_readable(1048064), '1Mi') - self.assertEquals(utils.human_readable(1048576), '1Mi') - self.assertEquals(utils.human_readable(1073741824), '1Gi') - self.assertEquals(utils.human_readable(1099511627776), '1Ti') - self.assertEquals(utils.human_readable(1125899906842624), '1Pi') - self.assertEquals(utils.human_readable(1152921504606846976), '1Ei') - self.assertEquals(utils.human_readable(1180591620717411303424), '1Zi') - self.assertEquals(utils.human_readable(1208925819614629174706176), - '1Yi') - self.assertEquals(utils.human_readable(1237940039285380274899124224), - '1024Yi') + self.assertEqual(utils.human_readable(0), '0') + self.assertEqual(utils.human_readable(1), '1') + self.assertEqual(utils.human_readable(10), '10') + self.assertEqual(utils.human_readable(100), '100') + self.assertEqual(utils.human_readable(999), '999') + self.assertEqual(utils.human_readable(1024), '1Ki') + self.assertEqual(utils.human_readable(1535), '1Ki') + self.assertEqual(utils.human_readable(1536), '2Ki') + self.assertEqual(utils.human_readable(1047552), '1023Ki') + self.assertEqual(utils.human_readable(1048063), '1023Ki') + self.assertEqual(utils.human_readable(1048064), '1Mi') + self.assertEqual(utils.human_readable(1048576), '1Mi') + self.assertEqual(utils.human_readable(1073741824), '1Gi') + self.assertEqual(utils.human_readable(1099511627776), '1Ti') + self.assertEqual(utils.human_readable(1125899906842624), '1Pi') + self.assertEqual(utils.human_readable(1152921504606846976), '1Ei') + self.assertEqual(utils.human_readable(1180591620717411303424), '1Zi') + self.assertEqual(utils.human_readable(1208925819614629174706176), + '1Yi') + self.assertEqual(utils.human_readable(1237940039285380274899124224), + '1024Yi') def test_validate_sync_to(self): fname = 'container-sync-realms.conf' @@ -2150,12 +2150,12 @@ cluster_dfw1 = http://dfw1.host/v1/ ('', (None, None, None, None))): if goodurl.startswith('//') and not realms_conf: - self.assertEquals( + self.assertEqual( utils.validate_sync_to( goodurl, ['1.1.1.1', '2.2.2.2'], realms_conf), (None, None, None, None)) else: - self.assertEquals( + self.assertEqual( utils.validate_sync_to( goodurl, ['1.1.1.1', '2.2.2.2'], realms_conf), result) @@ -2209,19 +2209,19 @@ cluster_dfw1 = http://dfw1.host/v1/ ("Invalid X-Container-Sync-To format " "'//us'", None, None, None))): if badurl.startswith('//') and not realms_conf: - self.assertEquals( + self.assertEqual( utils.validate_sync_to( badurl, ['1.1.1.1', '2.2.2.2'], realms_conf), (None, None, None, None)) else: - self.assertEquals( + self.assertEqual( utils.validate_sync_to( badurl, ['1.1.1.1', '2.2.2.2'], realms_conf), result) def test_TRUE_VALUES(self): for v in utils.TRUE_VALUES: - self.assertEquals(v, v.lower()) + self.assertEqual(v, v.lower()) def test_config_true_value(self): orig_trues = utils.TRUE_VALUES @@ -2253,7 +2253,7 @@ cluster_dfw1 = http://dfw1.host/v1/ if e.__class__ is not expected: raise else: - self.assertEquals(expected, rv) + self.assertEqual(expected, rv) def test_streq_const_time(self): self.assertTrue(utils.streq_const_time('abc123', 'abc123')) @@ -2352,12 +2352,12 @@ cluster_dfw1 = http://dfw1.host/v1/ utils.FALLOCATE_RESERVE = 1023 StatVFS.f_frsize = 1024 StatVFS.f_bavail = 1 - self.assertEquals(fallocate(0, 1, 0, ctypes.c_uint64(0)), 0) + self.assertEqual(fallocate(0, 1, 0, ctypes.c_uint64(0)), 0) # Want 1023 reserved, have 512 * 2 free, so succeeds utils.FALLOCATE_RESERVE = 1023 StatVFS.f_frsize = 512 StatVFS.f_bavail = 2 - self.assertEquals(fallocate(0, 1, 0, ctypes.c_uint64(0)), 0) + self.assertEqual(fallocate(0, 1, 0, ctypes.c_uint64(0)), 0) # Want 1024 reserved, have 1024 * 1 free, so fails utils.FALLOCATE_RESERVE = 1024 StatVFS.f_frsize = 1024 @@ -2367,7 +2367,7 @@ cluster_dfw1 = http://dfw1.host/v1/ fallocate(0, 1, 0, ctypes.c_uint64(0)) except OSError as err: exc = err - self.assertEquals(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 1024') + self.assertEqual(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 1024') # Want 1024 reserved, have 512 * 2 free, so fails utils.FALLOCATE_RESERVE = 1024 StatVFS.f_frsize = 512 @@ -2377,7 +2377,7 @@ cluster_dfw1 = http://dfw1.host/v1/ fallocate(0, 1, 0, ctypes.c_uint64(0)) except OSError as err: exc = err - self.assertEquals(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 1024') + self.assertEqual(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 1024') # Want 2048 reserved, have 1024 * 1 free, so fails utils.FALLOCATE_RESERVE = 2048 StatVFS.f_frsize = 1024 @@ -2387,7 +2387,7 @@ cluster_dfw1 = http://dfw1.host/v1/ fallocate(0, 1, 0, ctypes.c_uint64(0)) except OSError as err: exc = err - self.assertEquals(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 2048') + self.assertEqual(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 2048') # Want 2048 reserved, have 512 * 2 free, so fails utils.FALLOCATE_RESERVE = 2048 StatVFS.f_frsize = 512 @@ -2397,7 +2397,7 @@ cluster_dfw1 = http://dfw1.host/v1/ fallocate(0, 1, 0, ctypes.c_uint64(0)) except OSError as err: exc = err - self.assertEquals(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 2048') + self.assertEqual(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 2048') # Want 1023 reserved, have 1024 * 1 free, but file size is 1, so # fails utils.FALLOCATE_RESERVE = 1023 @@ -2408,19 +2408,19 @@ cluster_dfw1 = http://dfw1.host/v1/ fallocate(0, 1, 0, ctypes.c_uint64(1)) except OSError as err: exc = err - self.assertEquals(str(exc), 'FALLOCATE_RESERVE fail 1023 <= 1023') + self.assertEqual(str(exc), 'FALLOCATE_RESERVE fail 1023 <= 1023') # Want 1022 reserved, have 1024 * 1 free, and file size is 1, so # succeeds utils.FALLOCATE_RESERVE = 1022 StatVFS.f_frsize = 1024 StatVFS.f_bavail = 1 - self.assertEquals(fallocate(0, 1, 0, ctypes.c_uint64(1)), 0) + self.assertEqual(fallocate(0, 1, 0, ctypes.c_uint64(1)), 0) # Want 1023 reserved, have 1024 * 1 free, and file size is 0, so # succeeds utils.FALLOCATE_RESERVE = 1023 StatVFS.f_frsize = 1024 StatVFS.f_bavail = 1 - self.assertEquals(fallocate(0, 1, 0, ctypes.c_uint64(0)), 0) + self.assertEqual(fallocate(0, 1, 0, ctypes.c_uint64(0)), 0) # Want 1024 reserved, have 1024 * 1 free, and even though # file size is 0, since we're under the reserve, fails utils.FALLOCATE_RESERVE = 1024 @@ -2431,7 +2431,7 @@ cluster_dfw1 = http://dfw1.host/v1/ fallocate(0, 1, 0, ctypes.c_uint64(0)) except OSError as err: exc = err - self.assertEquals(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 1024') + self.assertEqual(str(exc), 'FALLOCATE_RESERVE fail 1024 <= 1024') finally: utils.FALLOCATE_RESERVE = orig_FALLOCATE_RESERVE utils.os.fstatvfs = orig_fstatvfs @@ -2454,23 +2454,23 @@ cluster_dfw1 = http://dfw1.host/v1/ # Ensure fallocate calls _sys_fallocate even with 0 bytes utils._sys_fallocate.last_call = None utils.fallocate(1234, 0) - self.assertEquals(utils._sys_fallocate.last_call, - [1234, 1, 0, 0]) + self.assertEqual(utils._sys_fallocate.last_call, + [1234, 1, 0, 0]) # Ensure fallocate calls _sys_fallocate even with negative bytes utils._sys_fallocate.last_call = None utils.fallocate(1234, -5678) - self.assertEquals(utils._sys_fallocate.last_call, - [1234, 1, 0, 0]) + self.assertEqual(utils._sys_fallocate.last_call, + [1234, 1, 0, 0]) # Ensure fallocate calls _sys_fallocate properly with positive # bytes utils._sys_fallocate.last_call = None utils.fallocate(1234, 1) - self.assertEquals(utils._sys_fallocate.last_call, - [1234, 1, 0, 1]) + self.assertEqual(utils._sys_fallocate.last_call, + [1234, 1, 0, 1]) utils._sys_fallocate.last_call = None utils.fallocate(1234, 10 * 1024 * 1024 * 1024) - self.assertEquals(utils._sys_fallocate.last_call, - [1234, 1, 0, 10 * 1024 * 1024 * 1024]) + self.assertEqual(utils._sys_fallocate.last_call, + [1234, 1, 0, 10 * 1024 * 1024 * 1024]) finally: utils._sys_fallocate = orig__sys_fallocate @@ -2478,38 +2478,38 @@ cluster_dfw1 = http://dfw1.host/v1/ fake_time = 1366428370.5163341 with patch.object(utils.time, 'time', return_value=fake_time): trans_id = utils.generate_trans_id('') - self.assertEquals(len(trans_id), 34) - self.assertEquals(trans_id[:2], 'tx') - self.assertEquals(trans_id[23], '-') - self.assertEquals(int(trans_id[24:], 16), int(fake_time)) + self.assertEqual(len(trans_id), 34) + self.assertEqual(trans_id[:2], 'tx') + self.assertEqual(trans_id[23], '-') + self.assertEqual(int(trans_id[24:], 16), int(fake_time)) with patch.object(utils.time, 'time', return_value=fake_time): trans_id = utils.generate_trans_id('-suffix') - self.assertEquals(len(trans_id), 41) - self.assertEquals(trans_id[:2], 'tx') - self.assertEquals(trans_id[34:], '-suffix') - self.assertEquals(trans_id[23], '-') - self.assertEquals(int(trans_id[24:34], 16), int(fake_time)) + self.assertEqual(len(trans_id), 41) + self.assertEqual(trans_id[:2], 'tx') + self.assertEqual(trans_id[34:], '-suffix') + self.assertEqual(trans_id[23], '-') + self.assertEqual(int(trans_id[24:34], 16), int(fake_time)) def test_get_trans_id_time(self): ts = utils.get_trans_id_time('tx8c8bc884cdaf499bb29429aa9c46946e') - self.assertEquals(ts, None) + self.assertEqual(ts, None) ts = utils.get_trans_id_time('tx1df4ff4f55ea45f7b2ec2-0051720c06') - self.assertEquals(ts, 1366428678) - self.assertEquals( + self.assertEqual(ts, 1366428678) + self.assertEqual( time.asctime(time.gmtime(ts)) + ' UTC', 'Sat Apr 20 03:31:18 2013 UTC') ts = utils.get_trans_id_time( 'tx1df4ff4f55ea45f7b2ec2-0051720c06-suffix') - self.assertEquals(ts, 1366428678) - self.assertEquals( + self.assertEqual(ts, 1366428678) + self.assertEqual( time.asctime(time.gmtime(ts)) + ' UTC', 'Sat Apr 20 03:31:18 2013 UTC') ts = utils.get_trans_id_time('') - self.assertEquals(ts, None) + self.assertEqual(ts, None) ts = utils.get_trans_id_time('garbage') - self.assertEquals(ts, None) + self.assertEqual(ts, None) ts = utils.get_trans_id_time('tx1df4ff4f55ea45f7b2ec2-almostright') - self.assertEquals(ts, None) + self.assertEqual(ts, None) def test_tpool_reraise(self): with patch.object(utils.tpool, 'execute', lambda f: f()): @@ -2777,23 +2777,23 @@ cluster_dfw1 = http://dfw1.host/v1/ shutil.rmtree(tmpdir) def test_parse_content_type(self): - self.assertEquals(utils.parse_content_type('text/plain'), - ('text/plain', [])) - self.assertEquals(utils.parse_content_type('text/plain;charset=utf-8'), - ('text/plain', [('charset', 'utf-8')])) - self.assertEquals( + self.assertEqual(utils.parse_content_type('text/plain'), + ('text/plain', [])) + self.assertEqual(utils.parse_content_type('text/plain;charset=utf-8'), + ('text/plain', [('charset', 'utf-8')])) + self.assertEqual( utils.parse_content_type('text/plain;hello="world";charset=utf-8'), ('text/plain', [('hello', '"world"'), ('charset', 'utf-8')])) - self.assertEquals( + self.assertEqual( utils.parse_content_type('text/plain; hello="world"; a=b'), ('text/plain', [('hello', '"world"'), ('a', 'b')])) - self.assertEquals( + self.assertEqual( utils.parse_content_type(r'text/plain; x="\""; a=b'), ('text/plain', [('x', r'"\""'), ('a', 'b')])) - self.assertEquals( + self.assertEqual( utils.parse_content_type(r'text/plain; x; a=b'), ('text/plain', [('x', ''), ('a', 'b')])) - self.assertEquals( + self.assertEqual( utils.parse_content_type(r'text/plain; x="\""; a'), ('text/plain', [('x', r'"\""'), ('a', '')])) @@ -2803,18 +2803,18 @@ cluster_dfw1 = http://dfw1.host/v1/ 'content_type': 'text/plain; hello="world"; swift_bytes=15'} utils.override_bytes_from_content_type(listing_dict, logger=FakeLogger()) - self.assertEquals(listing_dict['bytes'], 15) - self.assertEquals(listing_dict['content_type'], - 'text/plain;hello="world"') + self.assertEqual(listing_dict['bytes'], 15) + self.assertEqual(listing_dict['content_type'], + 'text/plain;hello="world"') listing_dict = { 'bytes': 1234, 'hash': 'asdf', 'name': 'zxcv', 'content_type': 'text/plain; hello="world"; swift_bytes=hey'} utils.override_bytes_from_content_type(listing_dict, logger=FakeLogger()) - self.assertEquals(listing_dict['bytes'], 1234) - self.assertEquals(listing_dict['content_type'], - 'text/plain;hello="world"') + self.assertEqual(listing_dict['bytes'], 1234) + self.assertEqual(listing_dict['content_type'], + 'text/plain;hello="world"') def test_clean_content_type(self): subtests = { @@ -2844,13 +2844,13 @@ cluster_dfw1 = http://dfw1.host/v1/ valid_utf8_str = utils.get_valid_utf8_str(account) account = 'abc_' + unicode_sample.encode('utf-8')[::-1] invalid_utf8_str = utils.get_valid_utf8_str(account) - self.assertEquals('abc_%EC%9D%BC%EC%98%81', - utils.quote(valid_utf8_str)) - self.assertEquals('abc_%EF%BF%BD%EF%BF%BD%EC%BC%9D%EF%BF%BD', - utils.quote(invalid_utf8_str)) + self.assertEqual('abc_%EC%9D%BC%EC%98%81', + utils.quote(valid_utf8_str)) + self.assertEqual('abc_%EF%BF%BD%EF%BF%BD%EC%BC%9D%EF%BF%BD', + utils.quote(invalid_utf8_str)) def test_get_hmac(self): - self.assertEquals( + self.assertEqual( utils.get_hmac('GET', '/path', 1, 'abc'), 'b17f6ff8da0e251737aa9e3ee69a881e3e092e2f') @@ -2860,16 +2860,16 @@ cluster_dfw1 = http://dfw1.host/v1/ '/sda1/p/a', environ={'REQUEST_METHOD': 'GET'}) res = Response() - self.assertEquals(None, utils.get_policy_index(req.headers, - res.headers)) + self.assertEqual(None, utils.get_policy_index(req.headers, + res.headers)) # The policy of a container can be specified by the response header req = Request.blank( '/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'}) res = Response(headers={'X-Backend-Storage-Policy-Index': '1'}) - self.assertEquals('1', utils.get_policy_index(req.headers, - res.headers)) + self.assertEqual('1', utils.get_policy_index(req.headers, + res.headers)) # The policy of an object to be created can be specified by the request # header @@ -2878,8 +2878,8 @@ cluster_dfw1 = http://dfw1.host/v1/ environ={'REQUEST_METHOD': 'PUT'}, headers={'X-Backend-Storage-Policy-Index': '2'}) res = Response() - self.assertEquals('2', utils.get_policy_index(req.headers, - res.headers)) + self.assertEqual('2', utils.get_policy_index(req.headers, + res.headers)) def test_get_log_line(self): req = Request.blank( @@ -2896,7 +2896,7 @@ cluster_dfw1 = http://dfw1.host/v1/ mock.MagicMock(side_effect=[time.gmtime(10001.0)])): with mock.patch( 'os.getpid', mock.MagicMock(return_value=server_pid)): - self.assertEquals( + self.assertEqual( exp_line, utils.get_log_line(req, res, trans_time, additional_info)) @@ -3109,15 +3109,15 @@ class ResellerConfReader(unittest.TestCase): conf, self.default_rules) self.assertEqual(prefixes, ['PRE1_', 'PRE2_']) - self.assertEquals(set(['role1', 'role2']), - set(options['PRE1_'].get('operator_roles'))) - self.assertEquals(['role5'], - options['PRE2_'].get('operator_roles')) - self.assertEquals(set(['role3', 'role4']), - set(options['PRE1_'].get('service_roles'))) - self.assertEquals(['role6'], options['PRE2_'].get('service_roles')) - self.assertEquals('', options['PRE1_'].get('require_group')) - self.assertEquals('pre2_group', options['PRE2_'].get('require_group')) + self.assertEqual(set(['role1', 'role2']), + set(options['PRE1_'].get('operator_roles'))) + self.assertEqual(['role5'], + options['PRE2_'].get('operator_roles')) + self.assertEqual(set(['role3', 'role4']), + set(options['PRE1_'].get('service_roles'))) + self.assertEqual(['role6'], options['PRE2_'].get('service_roles')) + self.assertEqual('', options['PRE1_'].get('require_group')) + self.assertEqual('pre2_group', options['PRE2_'].get('require_group')) def test_several_resellers_first_blank(self): conf = {'reseller_prefix': " '' , PRE2", @@ -3130,15 +3130,15 @@ class ResellerConfReader(unittest.TestCase): conf, self.default_rules) self.assertEqual(prefixes, ['', 'PRE2_']) - self.assertEquals(set(['role1', 'role2']), - set(options[''].get('operator_roles'))) - self.assertEquals(['role5'], - options['PRE2_'].get('operator_roles')) - self.assertEquals(set(['role3', 'role4']), - set(options[''].get('service_roles'))) - self.assertEquals(['role6'], options['PRE2_'].get('service_roles')) - self.assertEquals('', options[''].get('require_group')) - self.assertEquals('pre2_group', options['PRE2_'].get('require_group')) + self.assertEqual(set(['role1', 'role2']), + set(options[''].get('operator_roles'))) + self.assertEqual(['role5'], + options['PRE2_'].get('operator_roles')) + self.assertEqual(set(['role3', 'role4']), + set(options[''].get('service_roles'))) + self.assertEqual(['role6'], options['PRE2_'].get('service_roles')) + self.assertEqual('', options[''].get('require_group')) + self.assertEqual('pre2_group', options['PRE2_'].get('require_group')) def test_several_resellers_with_blank_comma(self): conf = {'reseller_prefix': "AUTH , '', PRE2", @@ -3150,20 +3150,20 @@ class ResellerConfReader(unittest.TestCase): prefixes, options = utils.config_read_reseller_options( conf, self.default_rules) self.assertEqual(prefixes, ['AUTH_', '', 'PRE2_']) - self.assertEquals(set(['admin', 'swiftoperator']), - set(options['AUTH_'].get('operator_roles'))) - self.assertEquals(set(['role1', 'role2']), - set(options[''].get('operator_roles'))) - self.assertEquals(['role5'], - options['PRE2_'].get('operator_roles')) - self.assertEquals([], - options['AUTH_'].get('service_roles')) - self.assertEquals(set(['role3', 'role4']), - set(options[''].get('service_roles'))) - self.assertEquals(['role6'], options['PRE2_'].get('service_roles')) - self.assertEquals('', options['AUTH_'].get('require_group')) - self.assertEquals('', options[''].get('require_group')) - self.assertEquals('pre2_group', options['PRE2_'].get('require_group')) + self.assertEqual(set(['admin', 'swiftoperator']), + set(options['AUTH_'].get('operator_roles'))) + self.assertEqual(set(['role1', 'role2']), + set(options[''].get('operator_roles'))) + self.assertEqual(['role5'], + options['PRE2_'].get('operator_roles')) + self.assertEqual([], + options['AUTH_'].get('service_roles')) + self.assertEqual(set(['role3', 'role4']), + set(options[''].get('service_roles'))) + self.assertEqual(['role6'], options['PRE2_'].get('service_roles')) + self.assertEqual('', options['AUTH_'].get('require_group')) + self.assertEqual('', options[''].get('require_group')) + self.assertEqual('pre2_group', options['PRE2_'].get('require_group')) def test_stray_comma(self): conf = {'reseller_prefix': "AUTH ,, PRE2", @@ -3175,15 +3175,15 @@ class ResellerConfReader(unittest.TestCase): prefixes, options = utils.config_read_reseller_options( conf, self.default_rules) self.assertEqual(prefixes, ['AUTH_', 'PRE2_']) - self.assertEquals(set(['admin', 'swiftoperator']), - set(options['AUTH_'].get('operator_roles'))) - self.assertEquals(['role5'], - options['PRE2_'].get('operator_roles')) - self.assertEquals([], - options['AUTH_'].get('service_roles')) - self.assertEquals(['role6'], options['PRE2_'].get('service_roles')) - self.assertEquals('', options['AUTH_'].get('require_group')) - self.assertEquals('pre2_group', options['PRE2_'].get('require_group')) + self.assertEqual(set(['admin', 'swiftoperator']), + set(options['AUTH_'].get('operator_roles'))) + self.assertEqual(['role5'], + options['PRE2_'].get('operator_roles')) + self.assertEqual([], + options['AUTH_'].get('service_roles')) + self.assertEqual(['role6'], options['PRE2_'].get('service_roles')) + self.assertEqual('', options['AUTH_'].get('require_group')) + self.assertEqual('pre2_group', options['PRE2_'].get('require_group')) def test_multiple_stray_commas_resellers(self): conf = {'reseller_prefix': ' , , ,'} @@ -3203,21 +3203,21 @@ class ResellerConfReader(unittest.TestCase): prefixes, options = utils.config_read_reseller_options( conf, self.default_rules) self.assertEqual(prefixes, ['AUTH_', '', 'PRE2_']) - self.assertEquals(set(['role1', 'role2']), - set(options['AUTH_'].get('operator_roles'))) - self.assertEquals(set(['role1', 'role2']), - set(options[''].get('operator_roles'))) - self.assertEquals(['role5'], - options['PRE2_'].get('operator_roles')) - self.assertEquals(set(['role3', 'role4']), - set(options['AUTH_'].get('service_roles'))) - self.assertEquals(set(['role3', 'role4']), - set(options[''].get('service_roles'))) - self.assertEquals(['role6'], options['PRE2_'].get('service_roles')) - self.assertEquals('auth_blank_group', - options['AUTH_'].get('require_group')) - self.assertEquals('auth_blank_group', options[''].get('require_group')) - self.assertEquals('pre2_group', options['PRE2_'].get('require_group')) + self.assertEqual(set(['role1', 'role2']), + set(options['AUTH_'].get('operator_roles'))) + self.assertEqual(set(['role1', 'role2']), + set(options[''].get('operator_roles'))) + self.assertEqual(['role5'], + options['PRE2_'].get('operator_roles')) + self.assertEqual(set(['role3', 'role4']), + set(options['AUTH_'].get('service_roles'))) + self.assertEqual(set(['role3', 'role4']), + set(options[''].get('service_roles'))) + self.assertEqual(['role6'], options['PRE2_'].get('service_roles')) + self.assertEqual('auth_blank_group', + options['AUTH_'].get('require_group')) + self.assertEqual('auth_blank_group', options[''].get('require_group')) + self.assertEqual('pre2_group', options['PRE2_'].get('require_group')) class TestSwiftInfo(unittest.TestCase): @@ -3388,7 +3388,7 @@ class TestSwiftInfo(unittest.TestCase): admin=True, disallowed_sections=['cap1.cap1_foo', 'cap3', 'cap4.a.b.c']) self.assertTrue('cap3' not in info) - self.assertEquals(info['cap1']['cap1_moo'], 'cap1_baa') + self.assertEqual(info['cap1']['cap1_moo'], 'cap1_baa') self.assertTrue('cap1_foo' not in info['cap1']) self.assertTrue('c' not in info['cap4']['a']['b']) self.assertEqual(info['cap4']['a']['b.c'], 'b.c') @@ -3402,7 +3402,7 @@ class TestSwiftInfo(unittest.TestCase): info = utils.get_swift_info( disallowed_sections=['cap2.cap1_foo', 'cap1.no_match', 'cap1.cap1_foo.no_match.no_match']) - self.assertEquals(info['cap1'], cap1) + self.assertEqual(info['cap1'], cap1) class TestFileLikeIter(unittest.TestCase): @@ -3412,7 +3412,7 @@ class TestFileLikeIter(unittest.TestCase): chunks = [] for chunk in utils.FileLikeIter(in_iter): chunks.append(chunk) - self.assertEquals(chunks, in_iter) + self.assertEqual(chunks, in_iter) def test_next(self): in_iter = ['abc', 'de', 'fghijk', 'l'] @@ -3424,12 +3424,12 @@ class TestFileLikeIter(unittest.TestCase): except StopIteration: break chunks.append(chunk) - self.assertEquals(chunks, in_iter) + self.assertEqual(chunks, in_iter) def test_read(self): in_iter = ['abc', 'de', 'fghijk', 'l'] iter_file = utils.FileLikeIter(in_iter) - self.assertEquals(iter_file.read(), ''.join(in_iter)) + self.assertEqual(iter_file.read(), ''.join(in_iter)) def test_read_with_size(self): in_iter = ['abc', 'de', 'fghijk', 'l'] @@ -3441,11 +3441,11 @@ class TestFileLikeIter(unittest.TestCase): break self.assertTrue(len(chunk) <= 2) chunks.append(chunk) - self.assertEquals(''.join(chunks), ''.join(in_iter)) + self.assertEqual(''.join(chunks), ''.join(in_iter)) def test_read_with_size_zero(self): # makes little sense, but file supports it, so... - self.assertEquals(utils.FileLikeIter('abc').read(0), '') + self.assertEqual(utils.FileLikeIter('abc').read(0), '') def test_readline(self): in_iter = ['abc\n', 'd', '\nef', 'g\nh', '\nij\n\nk\n', 'trailing.'] @@ -3456,18 +3456,18 @@ class TestFileLikeIter(unittest.TestCase): if not line: break lines.append(line) - self.assertEquals( + self.assertEqual( lines, [v if v == 'trailing.' else v + '\n' for v in ''.join(in_iter).split('\n')]) def test_readline2(self): - self.assertEquals( + self.assertEqual( utils.FileLikeIter(['abc', 'def\n']).readline(4), 'abcd') def test_readline3(self): - self.assertEquals( + self.assertEqual( utils.FileLikeIter(['a' * 1111, 'bc\ndef']).readline(), ('a' * 1111) + 'bc\n') @@ -3481,7 +3481,7 @@ class TestFileLikeIter(unittest.TestCase): if not line: break lines.append(line) - self.assertEquals( + self.assertEqual( lines, ['ab', 'c\n', 'd\n', 'ef', 'g\n', 'h\n', 'ij', '\n', '\n', 'k\n', 'tr', 'ai', 'li', 'ng', '.']) @@ -3489,7 +3489,7 @@ class TestFileLikeIter(unittest.TestCase): def test_readlines(self): in_iter = ['abc\n', 'd', '\nef', 'g\nh', '\nij\n\nk\n', 'trailing.'] lines = utils.FileLikeIter(in_iter).readlines() - self.assertEquals( + self.assertEqual( lines, [v if v == 'trailing.' else v + '\n' for v in ''.join(in_iter).split('\n')]) @@ -3503,14 +3503,14 @@ class TestFileLikeIter(unittest.TestCase): if not lines: break lists_of_lines.append(lines) - self.assertEquals( + self.assertEqual( lists_of_lines, [['ab'], ['c\n'], ['d\n'], ['ef'], ['g\n'], ['h\n'], ['ij'], ['\n', '\n'], ['k\n'], ['tr'], ['ai'], ['li'], ['ng'], ['.']]) def test_close(self): iter_file = utils.FileLikeIter('abcdef') - self.assertEquals(next(iter_file), 'a') + self.assertEqual(next(iter_file), 'a') iter_file.close() self.assertTrue(iter_file.closed) self.assertRaises(ValueError, iter_file.next) @@ -3654,37 +3654,37 @@ class TestStatsdLogging(unittest.TestCase): mock_controller = MockController(200) METHOD(mock_controller) - self.assertEquals(mock_controller.called, 'timing') - self.assertEquals(len(mock_controller.args), 2) - self.assertEquals(mock_controller.args[0], 'METHOD.timing') + self.assertEqual(mock_controller.called, 'timing') + self.assertEqual(len(mock_controller.args), 2) + self.assertEqual(mock_controller.args[0], 'METHOD.timing') self.assertTrue(mock_controller.args[1] > 0) mock_controller = MockController(404) METHOD(mock_controller) - self.assertEquals(len(mock_controller.args), 2) - self.assertEquals(mock_controller.called, 'timing') - self.assertEquals(mock_controller.args[0], 'METHOD.timing') + self.assertEqual(len(mock_controller.args), 2) + self.assertEqual(mock_controller.called, 'timing') + self.assertEqual(mock_controller.args[0], 'METHOD.timing') self.assertTrue(mock_controller.args[1] > 0) mock_controller = MockController(412) METHOD(mock_controller) - self.assertEquals(len(mock_controller.args), 2) - self.assertEquals(mock_controller.called, 'timing') - self.assertEquals(mock_controller.args[0], 'METHOD.timing') + self.assertEqual(len(mock_controller.args), 2) + self.assertEqual(mock_controller.called, 'timing') + self.assertEqual(mock_controller.args[0], 'METHOD.timing') self.assertTrue(mock_controller.args[1] > 0) mock_controller = MockController(416) METHOD(mock_controller) - self.assertEquals(len(mock_controller.args), 2) - self.assertEquals(mock_controller.called, 'timing') - self.assertEquals(mock_controller.args[0], 'METHOD.timing') + self.assertEqual(len(mock_controller.args), 2) + self.assertEqual(mock_controller.called, 'timing') + self.assertEqual(mock_controller.args[0], 'METHOD.timing') self.assertTrue(mock_controller.args[1] > 0) mock_controller = MockController(401) METHOD(mock_controller) - self.assertEquals(len(mock_controller.args), 2) - self.assertEquals(mock_controller.called, 'timing') - self.assertEquals(mock_controller.args[0], 'METHOD.errors.timing') + self.assertEqual(len(mock_controller.args), 2) + self.assertEqual(mock_controller.called, 'timing') + self.assertEqual(mock_controller.args[0], 'METHOD.errors.timing') self.assertTrue(mock_controller.args[1] > 0) @@ -3849,7 +3849,7 @@ class TestRateLimitedIterator(unittest.TestCase): got = self.run_under_pseudo_time(testfunc) # it's 11, not 10, because ratelimiting doesn't apply to the very # first element. - self.assertEquals(len(got), 11) + self.assertEqual(len(got), 11) def test_limit_after(self): @@ -3868,7 +3868,7 @@ class TestRateLimitedIterator(unittest.TestCase): got = self.run_under_pseudo_time(testfunc) # it's 16, not 15, because ratelimiting doesn't apply to the very # first element. - self.assertEquals(len(got), 16) + self.assertEqual(len(got), 16) class TestGreenthreadSafeIterator(unittest.TestCase): @@ -3881,7 +3881,7 @@ class TestGreenthreadSafeIterator(unittest.TestCase): def test_setup_works(self): # it should work without concurrent access - self.assertEquals([0, 1, 2, 3], list(UnsafeXrange(4))) + self.assertEqual([0, 1, 2, 3], list(UnsafeXrange(4))) iterable = UnsafeXrange(10) pile = eventlet.GreenPile(2) @@ -3899,7 +3899,7 @@ class TestGreenthreadSafeIterator(unittest.TestCase): for _ in range(2): pile.spawn(self.increment, iterable) response = sorted(sum([resp for resp in pile], [])) - self.assertEquals(list(range(1, 11)), response) + self.assertEqual(list(range(1, 11)), response) self.assertTrue( not unsafe_iterable.concurrent_call, 'concurrent call occurred') @@ -4123,28 +4123,28 @@ class TestStatsdLoggingDelegation(unittest.TestCase): unicode_sample = u'\uc77c\uc601' valid_utf8_str = unicode_sample.encode('utf-8') invalid_utf8_str = unicode_sample.encode('utf-8')[::-1] - self.assertEquals(valid_utf8_str, - utils.get_valid_utf8_str(valid_utf8_str)) - self.assertEquals(valid_utf8_str, - utils.get_valid_utf8_str(unicode_sample)) - self.assertEquals('\xef\xbf\xbd\xef\xbf\xbd\xec\xbc\x9d\xef\xbf\xbd', - utils.get_valid_utf8_str(invalid_utf8_str)) + self.assertEqual(valid_utf8_str, + utils.get_valid_utf8_str(valid_utf8_str)) + self.assertEqual(valid_utf8_str, + utils.get_valid_utf8_str(unicode_sample)) + self.assertEqual('\xef\xbf\xbd\xef\xbf\xbd\xec\xbc\x9d\xef\xbf\xbd', + utils.get_valid_utf8_str(invalid_utf8_str)) @reset_logger_state def test_thread_locals(self): logger = utils.get_logger(None) # test the setter logger.thread_locals = ('id', 'ip') - self.assertEquals(logger.thread_locals, ('id', 'ip')) + self.assertEqual(logger.thread_locals, ('id', 'ip')) # reset logger.thread_locals = (None, None) - self.assertEquals(logger.thread_locals, (None, None)) + self.assertEqual(logger.thread_locals, (None, None)) logger.txn_id = '1234' logger.client_ip = '1.2.3.4' - self.assertEquals(logger.thread_locals, ('1234', '1.2.3.4')) + self.assertEqual(logger.thread_locals, ('1234', '1.2.3.4')) logger.txn_id = '5678' logger.client_ip = '5.6.7.8' - self.assertEquals(logger.thread_locals, ('5678', '5.6.7.8')) + self.assertEqual(logger.thread_locals, ('5678', '5.6.7.8')) def test_no_fdatasync(self): called = [] @@ -4158,7 +4158,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase): with patch('swift.common.utils.os', NoFdatasync()): with patch('swift.common.utils.fsync', fsync): utils.fdatasync(12345) - self.assertEquals(called, [12345]) + self.assertEqual(called, [12345]) def test_yes_fdatasync(self): called = [] @@ -4170,7 +4170,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase): with patch('swift.common.utils.os', YesFdatasync()): utils.fdatasync(12345) - self.assertEquals(called, [12345]) + self.assertEqual(called, [12345]) def test_fsync_bad_fullsync(self): @@ -4197,7 +4197,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase): with patch('swift.common.utils.fcntl', FCNTL()): utils.fsync(12345) - self.assertEquals(called, [12345, 123]) + self.assertEqual(called, [12345, 123]) def test_fsync_no_fullsync(self): called = [] @@ -4211,7 +4211,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase): with patch('swift.common.utils.fcntl', FCNTL()): with patch('os.fsync', fsync): utils.fsync(12345) - self.assertEquals(called, [12345]) + self.assertEqual(called, [12345]) class TestThreadPool(unittest.TestCase): @@ -4254,8 +4254,8 @@ class TestThreadPool(unittest.TestCase): self.assertNotEquals(my_id, other_id) result = tp.run_in_thread(self._capture_args, 1, 2, bert='ernie') - self.assertEquals(result, {'args': (1, 2), - 'kwargs': {'bert': 'ernie'}}) + self.assertEqual(result, {'args': (1, 2), + 'kwargs': {'bert': 'ernie'}}) caught = False try: @@ -4273,8 +4273,8 @@ class TestThreadPool(unittest.TestCase): self.assertNotEquals(my_id, other_id) result = tp.force_run_in_thread(self._capture_args, 1, 2, bert='ernie') - self.assertEquals(result, {'args': (1, 2), - 'kwargs': {'bert': 'ernie'}}) + self.assertEqual(result, {'args': (1, 2), + 'kwargs': {'bert': 'ernie'}}) self.assertRaises(ValueError, tp.force_run_in_thread, self._raise_valueerror) @@ -4284,11 +4284,11 @@ class TestThreadPool(unittest.TestCase): my_id = self._thread_id() other_id = tp.run_in_thread(self._thread_id) - self.assertEquals(my_id, other_id) + self.assertEqual(my_id, other_id) result = tp.run_in_thread(self._capture_args, 1, 2, bert='ernie') - self.assertEquals(result, {'args': (1, 2), - 'kwargs': {'bert': 'ernie'}}) + self.assertEqual(result, {'args': (1, 2), + 'kwargs': {'bert': 'ernie'}}) self.assertRaises(ValueError, tp.run_in_thread, self._raise_valueerror) @@ -4301,8 +4301,8 @@ class TestThreadPool(unittest.TestCase): self.assertNotEquals(my_id, other_id) result = tp.force_run_in_thread(self._capture_args, 1, 2, bert='ernie') - self.assertEquals(result, {'args': (1, 2), - 'kwargs': {'bert': 'ernie'}}) + self.assertEqual(result, {'args': (1, 2), + 'kwargs': {'bert': 'ernie'}}) self.assertRaises(ValueError, tp.force_run_in_thread, self._raise_valueerror) @@ -4752,26 +4752,26 @@ class TestParseContentDisposition(unittest.TestCase): def test_basic_content_type(self): name, attrs = utils.parse_content_disposition('text/plain') - self.assertEquals(name, 'text/plain') - self.assertEquals(attrs, {}) + self.assertEqual(name, 'text/plain') + self.assertEqual(attrs, {}) def test_content_type_with_charset(self): name, attrs = utils.parse_content_disposition( 'text/plain; charset=UTF8') - self.assertEquals(name, 'text/plain') - self.assertEquals(attrs, {'charset': 'UTF8'}) + self.assertEqual(name, 'text/plain') + self.assertEqual(attrs, {'charset': 'UTF8'}) def test_content_disposition(self): name, attrs = utils.parse_content_disposition( 'form-data; name="somefile"; filename="test.html"') - self.assertEquals(name, 'form-data') - self.assertEquals(attrs, {'name': 'somefile', 'filename': 'test.html'}) + self.assertEqual(name, 'form-data') + self.assertEqual(attrs, {'name': 'somefile', 'filename': 'test.html'}) def test_content_disposition_without_white_space(self): name, attrs = utils.parse_content_disposition( 'form-data;name="somefile";filename="test.html"') - self.assertEquals(name, 'form-data') - self.assertEquals(attrs, {'name': 'somefile', 'filename': 'test.html'}) + self.assertEqual(name, 'form-data') + self.assertEqual(attrs, {'name': 'somefile', 'filename': 'test.html'}) class TestIterMultipartMimeDocuments(unittest.TestCase): @@ -4790,7 +4790,7 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): it = utils.iter_multipart_mime_documents(StringIO('--unique'), 'unique') fp = next(it) - self.assertEquals(fp.read(), '') + self.assertEqual(fp.read(), '') exc = None try: next(it) @@ -4802,7 +4802,7 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): it = utils.iter_multipart_mime_documents( StringIO('--unique\r\nabcdefg\r\n--unique--'), 'unique') fp = next(it) - self.assertEquals(fp.read(), 'abcdefg') + self.assertEqual(fp.read(), 'abcdefg') exc = None try: next(it) @@ -4815,9 +4815,9 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): StringIO('--unique\r\nabcdefg\r\n--unique\r\nhijkl\r\n--unique--'), 'unique') fp = next(it) - self.assertEquals(fp.read(), 'abcdefg') + self.assertEqual(fp.read(), 'abcdefg') fp = next(it) - self.assertEquals(fp.read(), 'hijkl') + self.assertEqual(fp.read(), 'hijkl') exc = None try: next(it) @@ -4830,13 +4830,13 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): StringIO('--unique\r\nabcdefg\r\n--unique\r\nhijkl\r\n--unique--'), 'unique') fp = next(it) - self.assertEquals(fp.read(2), 'ab') - self.assertEquals(fp.read(2), 'cd') - self.assertEquals(fp.read(2), 'ef') - self.assertEquals(fp.read(2), 'g') - self.assertEquals(fp.read(2), '') + self.assertEqual(fp.read(2), 'ab') + self.assertEqual(fp.read(2), 'cd') + self.assertEqual(fp.read(2), 'ef') + self.assertEqual(fp.read(2), 'g') + self.assertEqual(fp.read(2), '') fp = next(it) - self.assertEquals(fp.read(), 'hijkl') + self.assertEqual(fp.read(), 'hijkl') exc = None try: next(it) @@ -4849,10 +4849,10 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): StringIO('--unique\r\nabcdefg\r\n--unique\r\nhijkl\r\n--unique--'), 'unique') fp = next(it) - self.assertEquals(fp.read(65536), 'abcdefg') - self.assertEquals(fp.read(), '') + self.assertEqual(fp.read(65536), 'abcdefg') + self.assertEqual(fp.read(), '') fp = next(it) - self.assertEquals(fp.read(), 'hijkl') + self.assertEqual(fp.read(), 'hijkl') exc = None try: next(it) @@ -4866,10 +4866,10 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): '--unique\r\nhijkl\r\n--unique--'), 'unique') fp = next(it) - self.assertEquals(fp.read(65536), 'abcdefg') - self.assertEquals(fp.read(), '') + self.assertEqual(fp.read(65536), 'abcdefg') + self.assertEqual(fp.read(), '') fp = next(it) - self.assertEquals(fp.read(), 'hijkl') + self.assertEqual(fp.read(), 'hijkl') self.assertRaises(StopIteration, it.next) def test_broken_mid_stream(self): @@ -4878,7 +4878,7 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): it = utils.iter_multipart_mime_documents( StringIO('--unique\r\nabc'), 'unique') fp = next(it) - self.assertEquals(fp.read(), 'abc') + self.assertEqual(fp.read(), 'abc') exc = None try: next(it) @@ -4891,13 +4891,13 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): StringIO('--unique\r\nab\r\ncd\ref\ng\r\n--unique\r\nhi\r\n\r\n' 'jkl\r\n\r\n--unique--'), 'unique') fp = next(it) - self.assertEquals(fp.readline(), 'ab\r\n') - self.assertEquals(fp.readline(), 'cd\ref\ng') - self.assertEquals(fp.readline(), '') + self.assertEqual(fp.readline(), 'ab\r\n') + self.assertEqual(fp.readline(), 'cd\ref\ng') + self.assertEqual(fp.readline(), '') fp = next(it) - self.assertEquals(fp.readline(), 'hi\r\n') - self.assertEquals(fp.readline(), '\r\n') - self.assertEquals(fp.readline(), 'jkl\r\n') + self.assertEqual(fp.readline(), 'hi\r\n') + self.assertEqual(fp.readline(), '\r\n') + self.assertEqual(fp.readline(), 'jkl\r\n') exc = None try: next(it) @@ -4912,13 +4912,13 @@ class TestIterMultipartMimeDocuments(unittest.TestCase): 'unique', read_chunk_size=2) fp = next(it) - self.assertEquals(fp.readline(), 'ab\r\n') - self.assertEquals(fp.readline(), 'cd\ref\ng') - self.assertEquals(fp.readline(), '') + self.assertEqual(fp.readline(), 'ab\r\n') + self.assertEqual(fp.readline(), 'cd\ref\ng') + self.assertEqual(fp.readline(), '') fp = next(it) - self.assertEquals(fp.readline(), 'hi\r\n') - self.assertEquals(fp.readline(), '\r\n') - self.assertEquals(fp.readline(), 'jkl\r\n') + self.assertEqual(fp.readline(), 'hi\r\n') + self.assertEqual(fp.readline(), '\r\n') + self.assertEqual(fp.readline(), 'jkl\r\n') exc = None try: next(it) diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index e2b3a8c3a5..dcd6ede28e 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -73,41 +73,41 @@ class TestWSGI(unittest.TestCase): def test_monkey_patch_mimetools(self): sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).type, 'text/plain') + self.assertEqual(mimetools.Message(sio).type, 'text/plain') sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).plisttext, '') + self.assertEqual(mimetools.Message(sio).plisttext, '') sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).maintype, 'text') + self.assertEqual(mimetools.Message(sio).maintype, 'text') sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).subtype, 'plain') + self.assertEqual(mimetools.Message(sio).subtype, 'plain') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).type, 'text/html') + self.assertEqual(mimetools.Message(sio).type, 'text/html') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).plisttext, - '; charset=ISO-8859-4') + self.assertEqual(mimetools.Message(sio).plisttext, + '; charset=ISO-8859-4') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).maintype, 'text') + self.assertEqual(mimetools.Message(sio).maintype, 'text') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).subtype, 'html') + self.assertEqual(mimetools.Message(sio).subtype, 'html') wsgi.monkey_patch_mimetools() sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).type, None) + self.assertEqual(mimetools.Message(sio).type, None) sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).plisttext, '') + self.assertEqual(mimetools.Message(sio).plisttext, '') sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).maintype, None) + self.assertEqual(mimetools.Message(sio).maintype, None) sio = StringIO('blah') - self.assertEquals(mimetools.Message(sio).subtype, None) + self.assertEqual(mimetools.Message(sio).subtype, None) sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).type, 'text/html') + self.assertEqual(mimetools.Message(sio).type, 'text/html') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).plisttext, - '; charset=ISO-8859-4') + self.assertEqual(mimetools.Message(sio).plisttext, + '; charset=ISO-8859-4') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).maintype, 'text') + self.assertEqual(mimetools.Message(sio).maintype, 'text') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') - self.assertEquals(mimetools.Message(sio).subtype, 'html') + self.assertEqual(mimetools.Message(sio).subtype, 'html') def test_init_request_processor(self): config = """ @@ -150,7 +150,7 @@ class TestWSGI(unittest.TestCase): expected = swift.proxy.server.Application self.assertTrue(isinstance(app, expected)) # config settings applied to app instance - self.assertEquals(0.2, app.conn_timeout) + self.assertEqual(0.2, app.conn_timeout) # appconfig returns values from 'proxy-server' section expected = { '__file__': conf_file, @@ -158,10 +158,10 @@ class TestWSGI(unittest.TestCase): 'conn_timeout': '0.2', 'swift_dir': t, } - self.assertEquals(expected, conf) + self.assertEqual(expected, conf) # logger works logger.info('testing') - self.assertEquals('proxy-server', log_name) + self.assertEqual('proxy-server', log_name) @with_tempdir def test_loadapp_from_file(self, tempdir): @@ -215,7 +215,7 @@ class TestWSGI(unittest.TestCase): self.assertTrue(isinstance(app, expected)) self.assertTrue(isinstance(app.app, swift.proxy.server.Application)) # config settings applied to app instance - self.assertEquals(0.2, app.app.conn_timeout) + self.assertEqual(0.2, app.app.conn_timeout) # appconfig returns values from 'proxy-server' section expected = { '__file__': conf_dir, @@ -223,10 +223,10 @@ class TestWSGI(unittest.TestCase): 'conn_timeout': '0.2', 'swift_dir': conf_root, } - self.assertEquals(expected, conf) + self.assertEqual(expected, conf) # logger works logger.info('testing') - self.assertEquals('proxy-server', log_name) + self.assertEqual('proxy-server', log_name) def test_get_socket_bad_values(self): # first try with no port set @@ -287,14 +287,14 @@ class TestWSGI(unittest.TestCase): if hasattr(socket, 'TCP_KEEPIDLE'): expected_socket_opts[socket.IPPROTO_TCP][ socket.TCP_KEEPIDLE] = 600 - self.assertEquals(sock.opts, expected_socket_opts) + self.assertEqual(sock.opts, expected_socket_opts) # test ssl sock = wsgi.get_socket(ssl_conf) expected_kwargs = { 'certfile': '', 'keyfile': '', } - self.assertEquals(wsgi.ssl.wrap_socket_called, [expected_kwargs]) + self.assertEqual(wsgi.ssl.wrap_socket_called, [expected_kwargs]) finally: wsgi.listen = old_listen wsgi.ssl = old_ssl @@ -375,9 +375,9 @@ class TestWSGI(unittest.TestCase): logger = logging.getLogger('test') sock = listen(('localhost', 0)) wsgi.run_server(conf, logger, sock) - self.assertEquals('HTTP/1.0', - _wsgi.HttpProtocol.default_request_version) - self.assertEquals(30, _wsgi.WRITE_TIMEOUT) + self.assertEqual('HTTP/1.0', + _wsgi.HttpProtocol.default_request_version) + self.assertEqual(30, _wsgi.WRITE_TIMEOUT) _eventlet.hubs.use_hub.assert_called_with(utils.get_hub()) _eventlet.patcher.monkey_patch.assert_called_with(all=False, socket=True) @@ -385,12 +385,12 @@ class TestWSGI(unittest.TestCase): self.assertTrue(_wsgi.server.called) args, kwargs = _wsgi.server.call_args server_sock, server_app, server_logger = args - self.assertEquals(sock, server_sock) + self.assertEqual(sock, server_sock) self.assertTrue(isinstance(server_app, swift.proxy.server.Application)) - self.assertEquals(20, server_app.client_timeout) + self.assertEqual(20, server_app.client_timeout) self.assertTrue(isinstance(server_logger, wsgi.NullLogger)) self.assertTrue('custom_pool' in kwargs) - self.assertEquals(1000, kwargs['custom_pool'].size) + self.assertEqual(1000, kwargs['custom_pool'].size) def test_run_server_with_latest_eventlet(self): config = """ @@ -427,7 +427,7 @@ class TestWSGI(unittest.TestCase): self.assertTrue(_wsgi.server.called) args, kwargs = _wsgi.server.call_args - self.assertEquals(kwargs.get('capitalize_response_headers'), False) + self.assertEqual(kwargs.get('capitalize_response_headers'), False) def test_run_server_conf_dir(self): config_dir = { @@ -463,9 +463,9 @@ class TestWSGI(unittest.TestCase): wsgi.run_server(conf, logger, sock) self.assertTrue(os.environ['TZ'] is not '') - self.assertEquals('HTTP/1.0', - _wsgi.HttpProtocol.default_request_version) - self.assertEquals(30, _wsgi.WRITE_TIMEOUT) + self.assertEqual('HTTP/1.0', + _wsgi.HttpProtocol.default_request_version) + self.assertEqual(30, _wsgi.WRITE_TIMEOUT) _eventlet.hubs.use_hub.assert_called_with(utils.get_hub()) _eventlet.patcher.monkey_patch.assert_called_with(all=False, socket=True) @@ -473,7 +473,7 @@ class TestWSGI(unittest.TestCase): self.assertTrue(_wsgi.server.called) args, kwargs = _wsgi.server.call_args server_sock, server_app, server_logger = args - self.assertEquals(sock, server_sock) + self.assertEqual(sock, server_sock) self.assertTrue(isinstance(server_app, swift.proxy.server.Application)) self.assertTrue(isinstance(server_logger, wsgi.NullLogger)) self.assertTrue('custom_pool' in kwargs) @@ -514,9 +514,9 @@ class TestWSGI(unittest.TestCase): logger = logging.getLogger('test') sock = listen(('localhost', 0)) wsgi.run_server(conf, logger, sock) - self.assertEquals('HTTP/1.0', - _wsgi.HttpProtocol.default_request_version) - self.assertEquals(30, _wsgi.WRITE_TIMEOUT) + self.assertEqual('HTTP/1.0', + _wsgi.HttpProtocol.default_request_version) + self.assertEqual(30, _wsgi.WRITE_TIMEOUT) _eventlet.hubs.use_hub.assert_called_with(utils.get_hub()) _eventlet.patcher.monkey_patch.assert_called_with(all=False, socket=True) @@ -524,12 +524,12 @@ class TestWSGI(unittest.TestCase): self.assertTrue(mock_server.called) args, kwargs = mock_server.call_args server_sock, server_app, server_logger = args - self.assertEquals(sock, server_sock) + self.assertEqual(sock, server_sock) self.assertTrue(isinstance(server_app, swift.proxy.server.Application)) - self.assertEquals(20, server_app.client_timeout) + self.assertEqual(20, server_app.client_timeout) self.assertEqual(server_logger, None) self.assertTrue('custom_pool' in kwargs) - self.assertEquals(1000, kwargs['custom_pool'].size) + self.assertEqual(1000, kwargs['custom_pool'].size) def test_appconfig_dir_ignores_hidden_files(self): config_dir = { @@ -554,26 +554,26 @@ class TestWSGI(unittest.TestCase): 'here': os.path.join(path, 'server.conf.d'), 'port': '8080', } - self.assertEquals(conf, expected) + self.assertEqual(conf, expected) def test_pre_auth_wsgi_input(self): oldenv = {} newenv = wsgi.make_pre_authed_env(oldenv) self.assertTrue('wsgi.input' in newenv) - self.assertEquals(newenv['wsgi.input'].read(), '') + self.assertEqual(newenv['wsgi.input'].read(), '') oldenv = {'wsgi.input': BytesIO(b'original wsgi.input')} newenv = wsgi.make_pre_authed_env(oldenv) self.assertTrue('wsgi.input' in newenv) - self.assertEquals(newenv['wsgi.input'].read(), '') + self.assertEqual(newenv['wsgi.input'].read(), '') oldenv = {'swift.source': 'UT'} newenv = wsgi.make_pre_authed_env(oldenv) - self.assertEquals(newenv['swift.source'], 'UT') + self.assertEqual(newenv['swift.source'], 'UT') oldenv = {'swift.source': 'UT'} newenv = wsgi.make_pre_authed_env(oldenv, swift_source='SA') - self.assertEquals(newenv['swift.source'], 'SA') + self.assertEqual(newenv['swift.source'], 'SA') def test_pre_auth_req(self): class FakeReq(object): @@ -583,7 +583,7 @@ class TestWSGI(unittest.TestCase): environ = {} if headers is None: headers = {} - self.assertEquals(environ['swift.authorize']('test'), None) + self.assertEqual(environ['swift.authorize']('test'), None) self.assertFalse('HTTP_X_TRANS_ID' in environ) was_blank = Request.blank Request.blank = FakeReq.fake_blank @@ -597,23 +597,23 @@ class TestWSGI(unittest.TestCase): r = wsgi.make_pre_authed_request( {'HTTP_X_TRANS_ID': '1234'}, 'PUT', path=quote('/a space'), body='tester', headers={}) - self.assertEquals(r.path, quote('/a space')) + self.assertEqual(r.path, quote('/a space')) def test_pre_auth_req_drops_query(self): r = wsgi.make_pre_authed_request( {'QUERY_STRING': 'original'}, 'GET', 'path') - self.assertEquals(r.query_string, 'original') + self.assertEqual(r.query_string, 'original') r = wsgi.make_pre_authed_request( {'QUERY_STRING': 'original'}, 'GET', 'path?replacement') - self.assertEquals(r.query_string, 'replacement') + self.assertEqual(r.query_string, 'replacement') r = wsgi.make_pre_authed_request( {'QUERY_STRING': 'original'}, 'GET', 'path?') - self.assertEquals(r.query_string, '') + self.assertEqual(r.query_string, '') def test_pre_auth_req_with_body(self): r = wsgi.make_pre_authed_request( {'QUERY_STRING': 'original'}, 'GET', 'path', 'the body') - self.assertEquals(r.body, 'the body') + self.assertEqual(r.body, 'the body') def test_pre_auth_creates_script_name(self): e = wsgi.make_pre_authed_env({}) @@ -621,20 +621,20 @@ class TestWSGI(unittest.TestCase): def test_pre_auth_copies_script_name(self): e = wsgi.make_pre_authed_env({'SCRIPT_NAME': '/script_name'}) - self.assertEquals(e['SCRIPT_NAME'], '/script_name') + self.assertEqual(e['SCRIPT_NAME'], '/script_name') def test_pre_auth_copies_script_name_unless_path_overridden(self): e = wsgi.make_pre_authed_env({'SCRIPT_NAME': '/script_name'}, path='/override') - self.assertEquals(e['SCRIPT_NAME'], '') - self.assertEquals(e['PATH_INFO'], '/override') + self.assertEqual(e['SCRIPT_NAME'], '') + self.assertEqual(e['PATH_INFO'], '/override') def test_pre_auth_req_swift_source(self): r = wsgi.make_pre_authed_request( {'QUERY_STRING': 'original'}, 'GET', 'path', 'the body', swift_source='UT') - self.assertEquals(r.body, 'the body') - self.assertEquals(r.environ['swift.source'], 'UT') + self.assertEqual(r.body, 'the body') + self.assertEqual(r.environ['swift.source'], 'UT') def test_run_server_global_conf_callback(self): calls = defaultdict(lambda: 0) @@ -779,52 +779,52 @@ class TestWSGI(unittest.TestCase): def test_pre_auth_req_with_empty_env_no_path(self): r = wsgi.make_pre_authed_request( {}, 'GET') - self.assertEquals(r.path, quote('')) + self.assertEqual(r.path, quote('')) self.assertTrue('SCRIPT_NAME' in r.environ) self.assertTrue('PATH_INFO' in r.environ) def test_pre_auth_req_with_env_path(self): r = wsgi.make_pre_authed_request( {'PATH_INFO': '/unquoted path with %20'}, 'GET') - self.assertEquals(r.path, quote('/unquoted path with %20')) - self.assertEquals(r.environ['SCRIPT_NAME'], '') + self.assertEqual(r.path, quote('/unquoted path with %20')) + self.assertEqual(r.environ['SCRIPT_NAME'], '') def test_pre_auth_req_with_env_script(self): r = wsgi.make_pre_authed_request({'SCRIPT_NAME': '/hello'}, 'GET') - self.assertEquals(r.path, quote('/hello')) + self.assertEqual(r.path, quote('/hello')) def test_pre_auth_req_with_env_path_and_script(self): env = {'PATH_INFO': '/unquoted path with %20', 'SCRIPT_NAME': '/script'} r = wsgi.make_pre_authed_request(env, 'GET') expected_path = quote(env['SCRIPT_NAME'] + env['PATH_INFO']) - self.assertEquals(r.path, expected_path) + self.assertEqual(r.path, expected_path) env = {'PATH_INFO': '', 'SCRIPT_NAME': '/script'} r = wsgi.make_pre_authed_request(env, 'GET') - self.assertEquals(r.path, '/script') + self.assertEqual(r.path, '/script') env = {'PATH_INFO': '/path', 'SCRIPT_NAME': ''} r = wsgi.make_pre_authed_request(env, 'GET') - self.assertEquals(r.path, '/path') + self.assertEqual(r.path, '/path') env = {'PATH_INFO': '', 'SCRIPT_NAME': ''} r = wsgi.make_pre_authed_request(env, 'GET') - self.assertEquals(r.path, '') + self.assertEqual(r.path, '') def test_pre_auth_req_path_overrides_env(self): env = {'PATH_INFO': '/path', 'SCRIPT_NAME': '/script'} r = wsgi.make_pre_authed_request(env, 'GET', '/override') - self.assertEquals(r.path, '/override') - self.assertEquals(r.environ['SCRIPT_NAME'], '') - self.assertEquals(r.environ['PATH_INFO'], '/override') + self.assertEqual(r.path, '/override') + self.assertEqual(r.environ['SCRIPT_NAME'], '') + self.assertEqual(r.environ['PATH_INFO'], '/override') def test_make_env_keep_user_project_id(self): oldenv = {'HTTP_X_USER_ID': '1234', 'HTTP_X_PROJECT_ID': '5678'} newenv = wsgi.make_env(oldenv) self.assertTrue('HTTP_X_USER_ID' in newenv) - self.assertEquals(newenv['HTTP_X_USER_ID'], '1234') + self.assertEqual(newenv['HTTP_X_USER_ID'], '1234') self.assertTrue('HTTP_X_PROJECT_ID' in newenv) - self.assertEquals(newenv['HTTP_X_PROJECT_ID'], '5678') + self.assertEqual(newenv['HTTP_X_PROJECT_ID'], '5678') class TestServersPerPortStrategy(unittest.TestCase): @@ -1214,12 +1214,12 @@ class TestWSGIContext(unittest.TestCase): wc = wsgi.WSGIContext(app) r = Request.blank('/') it = wc._app_call(r.environ) - self.assertEquals(wc._response_status, '200 Ok') - self.assertEquals(''.join(it), 'Ok\n') + self.assertEqual(wc._response_status, '200 Ok') + self.assertEqual(''.join(it), 'Ok\n') r = Request.blank('/') it = wc._app_call(r.environ) - self.assertEquals(wc._response_status, '404 Not Found') - self.assertEquals(''.join(it), 'Ok\n') + self.assertEqual(wc._response_status, '404 Not Found') + self.assertEqual(''.join(it), 'Ok\n') def test_app_iter_is_closable(self): @@ -1234,7 +1234,7 @@ class TestWSGIContext(unittest.TestCase): wc = wsgi.WSGIContext(app) r = Request.blank('/') iterable = wc._app_call(r.environ) - self.assertEquals(wc._response_status, '200 OK') + self.assertEqual(wc._response_status, '200 OK') iterator = iter(iterable) self.assertEqual('aaaaa', next(iterator)) diff --git a/test/unit/container/test_server.py b/test/unit/container/test_server.py index 1bb60c9412..1b768aefa3 100644 --- a/test/unit/container/test_server.py +++ b/test/unit/container/test_server.py @@ -825,8 +825,8 @@ class TestContainerController(unittest.TestCase): resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 204) self.assertTrue('x-container-meta-test' not in resp.headers) - self.assertEquals(resp.headers.get('x-put-timestamp'), - '0000000004.00000') + self.assertEqual(resp.headers.get('x-put-timestamp'), + '0000000004.00000') def test_POST_HEAD_sys_metadata(self): prefix = get_sys_meta_prefix('container') diff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py index 63df22ad57..fa08bb2684 100644 --- a/test/unit/obj/test_replicator.py +++ b/test/unit/obj/test_replicator.py @@ -767,8 +767,8 @@ class TestObjectReplicator(unittest.TestCase): (0, '/sda/3'): 2, (1, '/sda/3'): 2, } - self.assertEquals(dict(found_replicate_calls), - expected_replicate_calls) + self.assertEqual(dict(found_replicate_calls), + expected_replicate_calls) def test_replicator_skips_bogus_partition_dirs(self): # A directory in the wrong place shouldn't crash the replicator diff --git a/test/unit/proxy/controllers/test_obj.py b/test/unit/proxy/controllers/test_obj.py index da3abd0c82..43f0000f97 100755 --- a/test/unit/proxy/controllers/test_obj.py +++ b/test/unit/proxy/controllers/test_obj.py @@ -2079,11 +2079,11 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase): with set_http_connect(*status_codes, body_iter=body_iter, headers=headers): resp = req.get_response(self.app) - self.assertEquals(resp.status_int, 200) - self.assertEquals(resp.body, '') + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.body, '') # 200OK shows original object content length - self.assertEquals(resp.headers['Content-Length'], '10') - self.assertEquals(resp.headers['Etag'], 'foo') + self.assertEqual(resp.headers['Content-Length'], '10') + self.assertEqual(resp.headers['Etag'], 'foo') # not found HEAD responses = [(404, '', {})] * self.replicas() * 2 @@ -2092,9 +2092,9 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase): with set_http_connect(*status_codes, body_iter=body_iter, headers=headers): resp = req.get_response(self.app) - self.assertEquals(resp.status_int, 404) + self.assertEqual(resp.status_int, 404) # 404 shows actual response body size (i.e. 0 for HEAD) - self.assertEquals(resp.headers['Content-Length'], '0') + self.assertEqual(resp.headers['Content-Length'], '0') def test_PUT_with_slow_commits(self): # It's important that this timeout be much less than the delay in @@ -2248,9 +2248,9 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase): with set_http_connect(*status_codes, body_iter=body_iter, headers=headers, expect_headers=expect_headers): resp = req.get_response(self.app) - self.assertEquals(resp.status_int, 416) - self.assertEquals(resp.content_length, len(range_not_satisfiable_body)) - self.assertEquals(resp.body, range_not_satisfiable_body) + self.assertEqual(resp.status_int, 416) + self.assertEqual(resp.content_length, len(range_not_satisfiable_body)) + self.assertEqual(resp.body, range_not_satisfiable_body) if __name__ == '__main__': diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index baa8762376..04a1033488 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -2218,8 +2218,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual(gotten_obj, obj) error_lines = prosrv.logger.get_lines_for_level('error') warn_lines = prosrv.logger.get_lines_for_level('warning') - self.assertEquals(len(error_lines), 0) # sanity - self.assertEquals(len(warn_lines), 0) # sanity + self.assertEqual(len(error_lines), 0) # sanity + self.assertEqual(len(warn_lines), 0) # sanity @unpatch_policies def test_conditional_GET_ec(self): @@ -2294,8 +2294,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual(resp.status_int, 304) error_lines = prosrv.logger.get_lines_for_level('error') warn_lines = prosrv.logger.get_lines_for_level('warning') - self.assertEquals(len(error_lines), 0) # sanity - self.assertEquals(len(warn_lines), 0) # sanity + self.assertEqual(len(error_lines), 0) # sanity + self.assertEqual(len(warn_lines), 0) # sanity @unpatch_policies def test_GET_ec_big(self): @@ -2353,8 +2353,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual(gotten_obj, obj) error_lines = prosrv.logger.get_lines_for_level('error') warn_lines = prosrv.logger.get_lines_for_level('warning') - self.assertEquals(len(error_lines), 0) # sanity - self.assertEquals(len(warn_lines), 0) # sanity + self.assertEqual(len(error_lines), 0) # sanity + self.assertEqual(len(warn_lines), 0) # sanity @unpatch_policies def test_GET_ec_failure_handling(self): @@ -2473,8 +2473,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual('chartreuse', headers['X-Object-Meta-Color']) error_lines = prosrv.logger.get_lines_for_level('error') warn_lines = prosrv.logger.get_lines_for_level('warning') - self.assertEquals(len(error_lines), 0) # sanity - self.assertEquals(len(warn_lines), 0) # sanity + self.assertEqual(len(error_lines), 0) # sanity + self.assertEqual(len(warn_lines), 0) # sanity @unpatch_policies def test_GET_ec_404(self): @@ -2495,8 +2495,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual(headers[:len(exp)], exp) error_lines = prosrv.logger.get_lines_for_level('error') warn_lines = prosrv.logger.get_lines_for_level('warning') - self.assertEquals(len(error_lines), 0) # sanity - self.assertEquals(len(warn_lines), 0) # sanity + self.assertEqual(len(error_lines), 0) # sanity + self.assertEqual(len(warn_lines), 0) # sanity @unpatch_policies def test_HEAD_ec_404(self): @@ -2517,8 +2517,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual(headers[:len(exp)], exp) error_lines = prosrv.logger.get_lines_for_level('error') warn_lines = prosrv.logger.get_lines_for_level('warning') - self.assertEquals(len(error_lines), 0) # sanity - self.assertEquals(len(warn_lines), 0) # sanity + self.assertEqual(len(error_lines), 0) # sanity + self.assertEqual(len(warn_lines), 0) # sanity def test_PUT_expect_header_zero_content_length(self): test_errors = []