From 239e94e62518f36601fb18119700269753d02a01 Mon Sep 17 00:00:00 2001 From: Bill Huber Date: Thu, 6 Aug 2015 09:28:51 -0500 Subject: [PATCH] pep8 fix: assertEquals -> assertEqual assertEquals is deprecated in py3 in the following dir: test/probe/* Change-Id: Ie08dd7a8a6c48e3452dfe4f2b41676330ce455d5 --- test/probe/test_account_failures.py | 82 +++++++++---------- test/probe/test_account_reaper.py | 8 +- test/probe/test_container_failures.py | 18 ++-- .../test_container_merge_policy_index.py | 2 +- test/probe/test_empty_device_handoff.py | 4 +- test/probe/test_object_failures.py | 16 ++-- test/probe/test_object_handoff.py | 8 +- 7 files changed, 69 insertions(+), 69 deletions(-) diff --git a/test/probe/test_account_failures.py b/test/probe/test_account_failures.py index ab6a48b5bc..f45394e6bf 100755 --- a/test/probe/test_account_failures.py +++ b/test/probe/test_account_failures.py @@ -35,20 +35,20 @@ class TestAccountFailures(ReplProbeTest): # Assert account level sees them headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '2') - self.assertEquals(headers['x-account-object-count'], '0') - self.assertEquals(headers['x-account-bytes-used'], '0') + self.assertEqual(headers['x-account-container-count'], '2') + self.assertEqual(headers['x-account-object-count'], '0') + self.assertEqual(headers['x-account-bytes-used'], '0') found1 = False found2 = False for container in containers: if container['name'] == container1: found1 = True - self.assertEquals(container['count'], 0) - self.assertEquals(container['bytes'], 0) + self.assertEqual(container['count'], 0) + self.assertEqual(container['bytes'], 0) elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 0) - self.assertEquals(container['bytes'], 0) + self.assertEqual(container['count'], 0) + self.assertEqual(container['bytes'], 0) self.assertTrue(found1) self.assertTrue(found2) @@ -57,20 +57,20 @@ class TestAccountFailures(ReplProbeTest): # Assert account level doesn't see it yet headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '2') - self.assertEquals(headers['x-account-object-count'], '0') - self.assertEquals(headers['x-account-bytes-used'], '0') + self.assertEqual(headers['x-account-container-count'], '2') + self.assertEqual(headers['x-account-object-count'], '0') + self.assertEqual(headers['x-account-bytes-used'], '0') found1 = False found2 = False for container in containers: if container['name'] == container1: found1 = True - self.assertEquals(container['count'], 0) - self.assertEquals(container['bytes'], 0) + self.assertEqual(container['count'], 0) + self.assertEqual(container['bytes'], 0) elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 0) - self.assertEquals(container['bytes'], 0) + self.assertEqual(container['count'], 0) + self.assertEqual(container['bytes'], 0) self.assertTrue(found1) self.assertTrue(found2) @@ -79,20 +79,20 @@ class TestAccountFailures(ReplProbeTest): # Assert account level now sees the container2/object1 headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '2') - self.assertEquals(headers['x-account-object-count'], '1') - self.assertEquals(headers['x-account-bytes-used'], '4') + self.assertEqual(headers['x-account-container-count'], '2') + self.assertEqual(headers['x-account-object-count'], '1') + self.assertEqual(headers['x-account-bytes-used'], '4') found1 = False found2 = False for container in containers: if container['name'] == container1: found1 = True - self.assertEquals(container['count'], 0) - self.assertEquals(container['bytes'], 0) + self.assertEqual(container['count'], 0) + self.assertEqual(container['bytes'], 0) elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 1) - self.assertEquals(container['bytes'], 4) + self.assertEqual(container['count'], 1) + self.assertEqual(container['bytes'], 4) self.assertTrue(found1) self.assertTrue(found2) @@ -111,9 +111,9 @@ class TestAccountFailures(ReplProbeTest): # Assert account level knows container1 is gone but doesn't know about # container2/object2 yet headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '1') - self.assertEquals(headers['x-account-object-count'], '1') - self.assertEquals(headers['x-account-bytes-used'], '4') + self.assertEqual(headers['x-account-container-count'], '1') + self.assertEqual(headers['x-account-object-count'], '1') + self.assertEqual(headers['x-account-bytes-used'], '4') found1 = False found2 = False for container in containers: @@ -121,8 +121,8 @@ class TestAccountFailures(ReplProbeTest): found1 = True elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 1) - self.assertEquals(container['bytes'], 4) + self.assertEqual(container['count'], 1) + self.assertEqual(container['bytes'], 4) self.assertTrue(not found1) self.assertTrue(found2) @@ -131,9 +131,9 @@ class TestAccountFailures(ReplProbeTest): # Assert account level now knows about container2/object2 headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '1') - self.assertEquals(headers['x-account-object-count'], '2') - self.assertEquals(headers['x-account-bytes-used'], '9') + self.assertEqual(headers['x-account-container-count'], '1') + self.assertEqual(headers['x-account-object-count'], '2') + self.assertEqual(headers['x-account-bytes-used'], '9') found1 = False found2 = False for container in containers: @@ -141,8 +141,8 @@ class TestAccountFailures(ReplProbeTest): found1 = True elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 2) - self.assertEquals(container['bytes'], 9) + self.assertEqual(container['count'], 2) + self.assertEqual(container['bytes'], 9) self.assertTrue(not found1) self.assertTrue(found2) @@ -154,9 +154,9 @@ class TestAccountFailures(ReplProbeTest): # new container2/object2 yet headers, containers = \ direct_client.direct_get_account(anodes[0], apart, self.account) - self.assertEquals(headers['x-account-container-count'], '2') - self.assertEquals(headers['x-account-object-count'], '1') - self.assertEquals(headers['x-account-bytes-used'], '4') + self.assertEqual(headers['x-account-container-count'], '2') + self.assertEqual(headers['x-account-object-count'], '1') + self.assertEqual(headers['x-account-bytes-used'], '4') found1 = False found2 = False for container in containers: @@ -164,8 +164,8 @@ class TestAccountFailures(ReplProbeTest): found1 = True elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 1) - self.assertEquals(container['bytes'], 4) + self.assertEqual(container['count'], 1) + self.assertEqual(container['bytes'], 4) self.assertTrue(found1) self.assertTrue(found2) @@ -175,9 +175,9 @@ class TestAccountFailures(ReplProbeTest): # Assert that server is now up to date headers, containers = \ direct_client.direct_get_account(anodes[0], apart, self.account) - self.assertEquals(headers['x-account-container-count'], '1') - self.assertEquals(headers['x-account-object-count'], '2') - self.assertEquals(headers['x-account-bytes-used'], '9') + self.assertEqual(headers['x-account-container-count'], '1') + self.assertEqual(headers['x-account-object-count'], '2') + self.assertEqual(headers['x-account-bytes-used'], '9') found1 = False found2 = False for container in containers: @@ -185,8 +185,8 @@ class TestAccountFailures(ReplProbeTest): found1 = True elif container['name'] == container2: found2 = True - self.assertEquals(container['count'], 2) - self.assertEquals(container['bytes'], 9) + self.assertEqual(container['count'], 2) + self.assertEqual(container['bytes'], 9) self.assertTrue(not found1) self.assertTrue(found2) diff --git a/test/probe/test_account_reaper.py b/test/probe/test_account_reaper.py index 7da9dcd39d..f5d2efee87 100644 --- a/test/probe/test_account_reaper.py +++ b/test/probe/test_account_reaper.py @@ -66,7 +66,7 @@ class TestAccountReaper(ReplProbeTest): direct_head_container(cnode, cpart, self.account, container) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) delete_time = err.http_headers.get( 'X-Backend-DELETE-Timestamp') # 'X-Backend-DELETE-Timestamp' confirms it was deleted @@ -91,7 +91,7 @@ class TestAccountReaper(ReplProbeTest): direct_get_object(node, part, self.account, container, obj, headers=headers) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) delete_time = err.http_headers.get('X-Backend-Timestamp') # 'X-Backend-Timestamp' confirms obj was deleted self.assertTrue(delete_time) @@ -114,7 +114,7 @@ class TestAccountReaper(ReplProbeTest): direct_head_container(cnode, cpart, self.account, container) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) delete_time = err.http_headers.get( 'X-Backend-DELETE-Timestamp') # 'X-Backend-DELETE-Timestamp' confirms it was deleted @@ -134,7 +134,7 @@ class TestAccountReaper(ReplProbeTest): direct_get_object(node, part, self.account, container, obj, headers=headers) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) delete_time = err.http_headers.get('X-Backend-Timestamp') # 'X-Backend-Timestamp' confirms obj was deleted self.assertTrue(delete_time) diff --git a/test/probe/test_container_failures.py b/test/probe/test_container_failures.py index 5eddad1464..d8c132c53d 100755 --- a/test/probe/test_container_failures.py +++ b/test/probe/test_container_failures.py @@ -70,7 +70,7 @@ class TestContainerFailures(ReplProbeTest): # Assert all container1 servers indicate container1 is alive and # well with object1 for cnode in cnodes: - self.assertEquals( + self.assertEqual( [o['name'] for o in direct_client.direct_get_container( cnode, cpart, self.account, container1)[1]], ['object1']) @@ -78,9 +78,9 @@ class TestContainerFailures(ReplProbeTest): # Assert account level also indicates container1 is alive and # well with object1 headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '1') - self.assertEquals(headers['x-account-object-count'], '1') - self.assertEquals(headers['x-account-bytes-used'], '3') + self.assertEqual(headers['x-account-container-count'], '1') + self.assertEqual(headers['x-account-object-count'], '1') + self.assertEqual(headers['x-account-bytes-used'], '3') def test_two_nodes_fail(self): # Create container1 @@ -118,15 +118,15 @@ class TestContainerFailures(ReplProbeTest): direct_client.direct_get_container(cnode, cpart, self.account, container1) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) else: self.fail("Expected ClientException but didn't get it") # Assert account level also indicates container1 is gone headers, containers = client.get_account(self.url, self.token) - self.assertEquals(headers['x-account-container-count'], '0') - self.assertEquals(headers['x-account-object-count'], '0') - self.assertEquals(headers['x-account-bytes-used'], '0') + self.assertEqual(headers['x-account-container-count'], '0') + self.assertEqual(headers['x-account-object-count'], '0') + self.assertEqual(headers['x-account-bytes-used'], '0') def _get_container_db_files(self, container): opart, onodes = self.container_ring.get_nodes(self.account, container) @@ -160,7 +160,7 @@ class TestContainerFailures(ReplProbeTest): try: client.delete_container(self.url, self.token, container) except client.ClientException as err: - self.assertEquals(err.http_status, 503) + self.assertEqual(err.http_status, 503) else: self.fail("Expected ClientException but didn't get it") else: diff --git a/test/probe/test_container_merge_policy_index.py b/test/probe/test_container_merge_policy_index.py index 1ce2c818dc..3472488f5f 100644 --- a/test/probe/test_container_merge_policy_index.py +++ b/test/probe/test_container_merge_policy_index.py @@ -336,7 +336,7 @@ class TestContainerMergePolicyIndex(ReplProbeTest): self.assertEqual(metadata['x-static-large-object'].lower(), 'true') for i, entry in enumerate(utils.json.loads(body)): for key in ('hash', 'bytes', 'name'): - self.assertEquals(entry[key], direct_manifest_data[i][key]) + self.assertEqual(entry[key], direct_manifest_data[i][key]) metadata, body = client.get_object( self.url, self.token, self.container_name, direct_manifest_name) self.assertEqual(metadata['x-static-large-object'].lower(), 'true') diff --git a/test/probe/test_empty_device_handoff.py b/test/probe/test_empty_device_handoff.py index f68ee6692b..c3138be05c 100755 --- a/test/probe/test_empty_device_handoff.py +++ b/test/probe/test_empty_device_handoff.py @@ -137,7 +137,7 @@ class TestEmptyDevice(ReplProbeTest): onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx}) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) self.assertFalse(os.path.exists(obj_dir)) else: self.fail("Expected ClientException but didn't get it") @@ -169,7 +169,7 @@ class TestEmptyDevice(ReplProbeTest): another_onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx}) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) else: self.fail("Expected ClientException but didn't get it") diff --git a/test/probe/test_object_failures.py b/test/probe/test_object_failures.py index eed5aca6a3..ba53177743 100755 --- a/test/probe/test_object_failures.py +++ b/test/probe/test_object_failures.py @@ -57,7 +57,7 @@ class TestObjectFailures(ReplProbeTest): self.policy.name}) client.put_object(self.url, self.token, container, obj, data) odata = client.get_object(self.url, self.token, container, obj)[-1] - self.assertEquals(odata, data) + self.assertEqual(odata, data) opart, onodes = self.object_ring.get_nodes( self.account, container, obj) onode = onodes[0] @@ -84,14 +84,14 @@ class TestObjectFailures(ReplProbeTest): odata = direct_client.direct_get_object( onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx})[-1] - self.assertEquals(odata, 'VERIFY') + self.assertEqual(odata, 'VERIFY') try: direct_client.direct_get_object( onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx}) raise Exception("Did not quarantine object") except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) def run_quarantine_range_etag(self): container = 'container-range-%s' % uuid4() @@ -111,7 +111,7 @@ class TestObjectFailures(ReplProbeTest): odata = direct_client.direct_get_object( onode, opart, self.account, container, obj, headers=req_headers)[-1] - self.assertEquals(odata, result) + self.assertEqual(odata, result) try: direct_client.direct_get_object( @@ -119,7 +119,7 @@ class TestObjectFailures(ReplProbeTest): 'X-Backend-Storage-Policy-Index': self.policy.idx}) raise Exception("Did not quarantine object") except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) def run_quarantine_zero_byte_get(self): container = 'container-zbyte-%s' % uuid4() @@ -137,7 +137,7 @@ class TestObjectFailures(ReplProbeTest): self.policy.idx}) raise Exception("Did not quarantine object") except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) def run_quarantine_zero_byte_head(self): container = 'container-zbyte-%s' % uuid4() @@ -155,7 +155,7 @@ class TestObjectFailures(ReplProbeTest): self.policy.idx}) raise Exception("Did not quarantine object") except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) def run_quarantine_zero_byte_post(self): container = 'container-zbyte-%s' % uuid4() @@ -177,7 +177,7 @@ class TestObjectFailures(ReplProbeTest): response_timeout=1) raise Exception("Did not quarantine object") except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) def test_runner(self): self.run_quarantine() diff --git a/test/probe/test_object_handoff.py b/test/probe/test_object_handoff.py index 37fb7626b5..c7df4b9e07 100755 --- a/test/probe/test_object_handoff.py +++ b/test/probe/test_object_handoff.py @@ -102,7 +102,7 @@ class TestObjectHandoff(ReplProbeTest): onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx}) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) else: self.fail("Expected ClientException but didn't get it") @@ -136,7 +136,7 @@ class TestObjectHandoff(ReplProbeTest): another_onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx}) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) else: self.fail("Expected ClientException but didn't get it") @@ -160,7 +160,7 @@ class TestObjectHandoff(ReplProbeTest): try: client.head_object(self.url, self.token, container, obj) except client.ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) else: self.fail("Expected ClientException but didn't get it") @@ -206,7 +206,7 @@ class TestObjectHandoff(ReplProbeTest): another_onode, opart, self.account, container, obj, headers={ 'X-Backend-Storage-Policy-Index': self.policy.idx}) except ClientException as err: - self.assertEquals(err.http_status, 404) + self.assertEqual(err.http_status, 404) else: self.fail("Expected ClientException but didn't get it")