From ee9458a250cb108e84eb5d02788cab002f0fca8b Mon Sep 17 00:00:00 2001 From: lingyongxu Date: Wed, 7 Jun 2017 11:37:01 +0800 Subject: [PATCH] Using assertIsNone() instead of assertEqual(None) Following OpenStack Style Guidelines: [1] http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises [H203] Unit test assertions tend to give better messages for more specific assertions. As a result, assertIsNone(...) is preferred over assertEqual(None, ...) and assertIs(..., None) Change-Id: If4db8872c4f5705c1fff017c4891626e9ce4d1e4 --- test/unit/common/middleware/test_bulk.py | 4 +- test/unit/common/middleware/test_except.py | 12 ++-- test/unit/common/middleware/test_formpost.py | 66 +++++++++---------- .../common/middleware/test_keystoneauth.py | 2 +- .../common/middleware/test_list_endpoints.py | 2 +- test/unit/common/middleware/test_memcache.py | 2 +- test/unit/common/middleware/test_slo.py | 8 +-- test/unit/common/middleware/test_tempauth.py | 22 +++---- test/unit/common/middleware/test_tempurl.py | 10 +-- .../unit/common/test_container_sync_realms.py | 10 +-- test/unit/common/test_db_replicator.py | 2 +- test/unit/common/test_direct_client.py | 6 +- test/unit/common/test_header_key_dict.py | 2 +- test/unit/common/test_manager.py | 8 +-- test/unit/common/test_memcached.py | 8 +-- test/unit/common/test_request_helpers.py | 2 +- test/unit/common/test_swob.py | 28 ++++---- test/unit/common/test_utils.py | 14 ++-- test/unit/common/test_wsgi.py | 8 +-- test/unit/container/test_reconciler.py | 6 +- test/unit/container/test_server.py | 6 +- test/unit/container/test_sync.py | 16 ++--- test/unit/obj/test_diskfile.py | 16 ++--- test/unit/obj/test_server.py | 4 +- test/unit/obj/test_ssync_receiver.py | 10 +-- 25 files changed, 137 insertions(+), 137 deletions(-) diff --git a/test/unit/common/middleware/test_bulk.py b/test/unit/common/middleware/test_bulk.py index 7399b00231..dc9be5647c 100644 --- a/test/unit/common/middleware/test_bulk.py +++ b/test/unit/common/middleware/test_bulk.py @@ -226,8 +226,8 @@ class TestUntarMetadata(unittest.TestCase): put2_headers = HeaderKeyDict(self.app.calls_with_headers[2][2]) self.assertEqual(put2_headers.get('X-Object-Meta-Muppet'), 'bert') self.assertEqual(put2_headers.get('X-Object-Meta-Cat'), 'fluffy') - self.assertEqual(put2_headers.get('Content-Type'), None) - self.assertEqual(put2_headers.get('X-Object-Meta-Blah'), None) + self.assertIsNone(put2_headers.get('Content-Type')) + self.assertIsNone(put2_headers.get('X-Object-Meta-Blah')) class TestUntar(unittest.TestCase): diff --git a/test/unit/common/middleware/test_except.py b/test/unit/common/middleware/test_except.py index a3b2587d9b..36996b457e 100644 --- a/test/unit/common/middleware/test_except.py +++ b/test/unit/common/middleware/test_except.py @@ -70,7 +70,7 @@ class TestCatchErrors(unittest.TestCase): self.assertEqual(list(resp), ['An error occurred']) def test_trans_id_header_pass(self): - self.assertEqual(self.logger.txn_id, None) + self.assertIsNone(self.logger.txn_id) app = catch_errors.CatchErrorMiddleware(FakeApp(), {}) req = Request.blank('/v1/a/c/o') @@ -78,7 +78,7 @@ class TestCatchErrors(unittest.TestCase): self.assertEqual(len(self.logger.txn_id), 34) # 32 hex + 'tx' def test_trans_id_header_fail(self): - self.assertEqual(self.logger.txn_id, None) + self.assertIsNone(self.logger.txn_id) app = catch_errors.CatchErrorMiddleware(FakeApp(True), {}) req = Request.blank('/v1/a/c/o') @@ -93,7 +93,7 @@ class TestCatchErrors(unittest.TestCase): self.assertEqual(list(resp), ['An error occurred']) def test_trans_id_header_suffix(self): - self.assertEqual(self.logger.txn_id, None) + self.assertIsNone(self.logger.txn_id) app = catch_errors.CatchErrorMiddleware( FakeApp(), {'trans_id_suffix': '-stuff'}) @@ -102,7 +102,7 @@ class TestCatchErrors(unittest.TestCase): self.assertTrue(self.logger.txn_id.endswith('-stuff')) def test_trans_id_header_extra(self): - self.assertEqual(self.logger.txn_id, None) + self.assertIsNone(self.logger.txn_id) app = catch_errors.CatchErrorMiddleware( FakeApp(), {'trans_id_suffix': '-fromconf'}) @@ -112,7 +112,7 @@ class TestCatchErrors(unittest.TestCase): self.assertTrue(self.logger.txn_id.endswith('-fromconf-fromuser')) def test_trans_id_header_extra_length_limit(self): - self.assertEqual(self.logger.txn_id, None) + self.assertIsNone(self.logger.txn_id) app = catch_errors.CatchErrorMiddleware( FakeApp(), {'trans_id_suffix': '-fromconf'}) @@ -123,7 +123,7 @@ class TestCatchErrors(unittest.TestCase): '-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) def test_trans_id_header_extra_quoted(self): - self.assertEqual(self.logger.txn_id, None) + self.assertIsNone(self.logger.txn_id) app = catch_errors.CatchErrorMiddleware(FakeApp(), {}) req = Request.blank('/v1/a/c/o', diff --git a/test/unit/common/middleware/test_formpost.py b/test/unit/common/middleware/test_formpost.py index c5fbc027a4..93a5d3bfd6 100644 --- a/test/unit/common/middleware/test_formpost.py +++ b/test/unit/common/middleware/test_formpost.py @@ -390,7 +390,7 @@ class TestFormPost(unittest.TestCase): if h.lower() == 'location': location = v self.assertEqual(location, 'http://brim.net?status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('http://brim.net?status=201&message=' in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -508,7 +508,7 @@ class TestFormPost(unittest.TestCase): if h.lower() == 'location': location = v self.assertEqual(location, 'http://brim.net?status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('http://brim.net?status=201&message=' in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -629,7 +629,7 @@ class TestFormPost(unittest.TestCase): if h.lower() == 'location': location = v self.assertEqual(location, 'http://brim.net?status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('http://brim.net?status=201&message=' in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -746,7 +746,7 @@ class TestFormPost(unittest.TestCase): if h.lower() == 'location': location = v self.assertEqual(location, 'http://brim.net?status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('http://brim.net?status=201&message=' in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -785,7 +785,7 @@ class TestFormPost(unittest.TestCase): headers = headers[0] exc_info = exc_info[0] self.assertEqual(status, '400 Bad Request') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('FormPost: invalid starting boundary' in body) self.assertEqual(len(self.app.requests), 0) @@ -817,7 +817,7 @@ class TestFormPost(unittest.TestCase): headers = headers[0] exc_info = exc_info[0] self.assertEqual(status, '400 Bad Request') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('FormPost: max_file_size exceeded' in body) self.assertEqual(len(self.app.requests), 0) @@ -856,7 +856,7 @@ class TestFormPost(unittest.TestCase): self.assertEqual( location, 'http://brim.net?status=400&message=max%20file%20count%20exceeded') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue( 'http://brim.net?status=400&message=max%20file%20count%20exceeded' in body) @@ -895,7 +895,7 @@ class TestFormPost(unittest.TestCase): # Make sure we 201 Created, which means we made the final subrequest # (and FakeApp verifies that no QUERY_STRING got passed). self.assertEqual(status, '201 Created') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('201 Created' in body) self.assertEqual(len(self.app.requests), 2) @@ -932,7 +932,7 @@ class TestFormPost(unittest.TestCase): if h.lower() == 'location': location = v self.assertEqual(location, 'http://brim.net?status=404&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue('http://brim.net?status=404&message=' in body) self.assertEqual(len(self.app.requests), 1) @@ -1021,7 +1021,7 @@ class TestFormPost(unittest.TestCase): self.assertEqual( location, ('a' * formpost.MAX_VALUE_LENGTH) + '?status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue( ('a' * formpost.MAX_VALUE_LENGTH) + '?status=201&message=' in body) self.assertEqual(len(self.app.requests), 2) @@ -1093,7 +1093,7 @@ class TestFormPost(unittest.TestCase): self.assertEqual( location, 'http://brim.net?status=400&message=no%20files%20to%20process') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue( 'http://brim.net?status=400&message=no%20files%20to%20process' in body) @@ -1249,7 +1249,7 @@ class TestFormPost(unittest.TestCase): if h.lower() == 'location': location = v self.assertEqual(location, 'http://redirect?status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue(location in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -1289,7 +1289,7 @@ class TestFormPost(unittest.TestCase): location = v self.assertEqual(location, 'http://redirect?one=two&status=201&message=') - self.assertEqual(exc_info, None) + self.assertIsNone(exc_info) self.assertTrue(location in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -1326,8 +1326,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('201 Created' in body) self.assertEqual(len(self.app.requests), 2) self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n') @@ -1362,8 +1362,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Form Expired' in body) def test_no_redirect_invalid_sig(self): @@ -1396,8 +1396,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Invalid Signature' in body) def test_no_redirect_with_error(self): @@ -1429,8 +1429,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: invalid starting boundary' in body) def test_no_v1(self): @@ -1462,8 +1462,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Invalid Signature' in body) def test_empty_v1(self): @@ -1495,8 +1495,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Invalid Signature' in body) def test_empty_account(self): @@ -1528,8 +1528,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Invalid Signature' in body) def test_wrong_account(self): @@ -1563,8 +1563,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Invalid Signature' in body) def test_no_container(self): @@ -1596,8 +1596,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: Invalid Signature' in body) def test_completely_non_int_expires(self): @@ -1634,8 +1634,8 @@ class TestFormPost(unittest.TestCase): for h, v in headers: if h.lower() == 'location': location = v - self.assertEqual(location, None) - self.assertEqual(exc_info, None) + self.assertIsNone(location) + self.assertIsNone(exc_info) self.assertTrue('FormPost: expired not an integer' in body) def test_x_delete_at(self): diff --git a/test/unit/common/middleware/test_keystoneauth.py b/test/unit/common/middleware/test_keystoneauth.py index e8f29b5719..388e7955b8 100644 --- a/test/unit/common/middleware/test_keystoneauth.py +++ b/test/unit/common/middleware/test_keystoneauth.py @@ -868,7 +868,7 @@ class TestAuthorize(BaseTestAuthorize): self._get_identity(tenant_id='test', roles=['got_erased'])) authorize_resp = the_env['swift.authorize'](subreq) - self.assertEqual(authorize_resp, None) + self.assertIsNone(authorize_resp) def test_names_disallowed_in_acls_outside_default_domain(self): id = self._get_identity_for_v2(user_domain_id='non-default', diff --git a/test/unit/common/middleware/test_list_endpoints.py b/test/unit/common/middleware/test_list_endpoints.py index bd366fb159..e96bd93bad 100644 --- a/test/unit/common/middleware/test_list_endpoints.py +++ b/test/unit/common/middleware/test_list_endpoints.py @@ -191,7 +191,7 @@ class TestListEndpoints(unittest.TestCase): self.assertEqual(version, guessed_version) self.assertEqual(account, 'c') self.assertEqual(container, 'o') - self.assertEqual(obj, None) + self.assertIsNone(obj) def test_get_object_ring(self): self.assertEqual(isinstance(self.list_endpoints.get_object_ring(0), diff --git a/test/unit/common/middleware/test_memcache.py b/test/unit/common/middleware/test_memcache.py index 286b707e2a..4db530c3a1 100644 --- a/test/unit/common/middleware/test_memcache.py +++ b/test/unit/common/middleware/test_memcache.py @@ -147,7 +147,7 @@ class TestCacheMiddleware(unittest.TestCase): exc = err finally: memcache.ConfigParser = orig_parser - self.assertEqual(exc, None) + self.assertIsNone(exc) def test_conf_default(self): orig_parser = memcache.ConfigParser diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index c1746ceb0d..905755cf3b 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -2034,10 +2034,10 @@ class TestSloGetManifest(SloTestCase): headers = [c[2] for c in self.app.calls_with_headers] self.assertEqual(headers[0].get('Range'), 'bytes=5-29') - self.assertEqual(headers[1].get('Range'), None) - self.assertEqual(headers[2].get('Range'), None) - self.assertEqual(headers[3].get('Range'), None) - self.assertEqual(headers[4].get('Range'), None) + self.assertIsNone(headers[1].get('Range')) + self.assertIsNone(headers[2].get('Range')) + self.assertIsNone(headers[3].get('Range')) + self.assertIsNone(headers[4].get('Range')) def test_range_get_manifest_first_byte(self): req = Request.blank( diff --git a/test/unit/common/middleware/test_tempauth.py b/test/unit/common/middleware/test_tempauth.py index 0f94c86125..0eccb73ade 100644 --- a/test/unit/common/middleware/test_tempauth.py +++ b/test/unit/common/middleware/test_tempauth.py @@ -330,7 +330,7 @@ class TestAuth(unittest.TestCase): def test_authorize_account_access(self): req = self._make_request('/v1/AUTH_cfa') req.remote_user = 'act:usr,act,AUTH_cfa' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) req = self._make_request('/v1/AUTH_cfa') req.remote_user = 'act:usr,act' resp = self.test_auth.authorize(req) @@ -346,11 +346,11 @@ class TestAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_cfa') req.remote_user = 'act:usr,act' req.acl = 'act' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) req = self._make_request('/v1/AUTH_cfa') req.remote_user = 'act:usr,act' req.acl = 'act:usr' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) req = self._make_request('/v1/AUTH_cfa') req.remote_user = 'act:usr,act' req.acl = 'act2' @@ -374,7 +374,7 @@ class TestAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_cfa/c') req.remote_user = 'act:usr' req.acl = '.r:*,act:usr' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) def test_authorize_acl_referrer_access(self): self.test_auth = auth.filter_factory({})( @@ -386,7 +386,7 @@ class TestAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_cfa/c') req.remote_user = 'act:usr,act' req.acl = '.r:*,.rlistings' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) req = self._make_request('/v1/AUTH_cfa/c') req.remote_user = 'act:usr,act' req.acl = '.r:*' # No listings allowed @@ -401,7 +401,7 @@ class TestAuth(unittest.TestCase): req.remote_user = 'act:usr,act' req.referer = 'http://www.example.com/index.html' req.acl = '.r:.example.com,.rlistings' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) req = self._make_request('/v1/AUTH_cfa/c') resp = self.test_auth.authorize(req) self.assertEqual(resp.status_int, 401) @@ -409,7 +409,7 @@ class TestAuth(unittest.TestCase): 'Swift realm="AUTH_cfa"') req = self._make_request('/v1/AUTH_cfa/c') req.acl = '.r:*,.rlistings' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) req = self._make_request('/v1/AUTH_cfa/c') req.acl = '.r:*' # No listings allowed resp = self.test_auth.authorize(req) @@ -425,7 +425,7 @@ class TestAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_cfa/c') req.referer = 'http://www.example.com/index.html' req.acl = '.r:.example.com,.rlistings' - self.assertEqual(self.test_auth.authorize(req), None) + self.assertIsNone(self.test_auth.authorize(req)) def test_detect_reseller_request(self): req = self._make_request('/v1/AUTH_admin', @@ -462,7 +462,7 @@ class TestAuth(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT'}) req.remote_user = 'act:usr,act,.reseller_admin' resp = self.test_auth.authorize(req) - self.assertEqual(resp, None) + self.assertIsNone(resp) # .super_admin is not something the middleware should ever see or care # about @@ -498,7 +498,7 @@ class TestAuth(unittest.TestCase): environ={'REQUEST_METHOD': 'DELETE'}) req.remote_user = 'act:usr,act,.reseller_admin' resp = self.test_auth.authorize(req) - self.assertEqual(resp, None) + self.assertIsNone(resp) # .super_admin is not something the middleware should ever see or care # about @@ -854,7 +854,7 @@ class TestAuth(unittest.TestCase): req = self._make_request('/v1/AUTH_cfa/c/o', environ={'REQUEST_METHOD': 'OPTIONS'}) resp = self.test_auth.authorize(req) - self.assertEqual(resp, None) + self.assertIsNone(resp) def test_get_user_group(self): # More tests in TestGetUserGroups class diff --git a/test/unit/common/middleware/test_tempurl.py b/test/unit/common/middleware/test_tempurl.py index 0b3b1d3c35..1cab313738 100644 --- a/test/unit/common/middleware/test_tempurl.py +++ b/test/unit/common/middleware/test_tempurl.py @@ -702,9 +702,9 @@ class TestTempURL(unittest.TestCase): # Requests for other objects happen if, for example, you're # downloading a large object or creating a large-object manifest. oo_resp = authorize(req_other_object) - self.assertEqual(oo_resp, None) + self.assertIsNone(oo_resp) oc_resp = authorize(req_other_container) - self.assertEqual(oc_resp, None) + self.assertIsNone(oc_resp) oa_resp = authorize(req_other_account) self.assertEqual(oa_resp.status_int, 401) @@ -721,7 +721,7 @@ class TestTempURL(unittest.TestCase): authorize = req.environ['swift.authorize'] oo_resp = authorize(req_other_object) - self.assertEqual(oo_resp, None) + self.assertIsNone(oo_resp) oc_resp = authorize(req_other_container) self.assertEqual(oc_resp.status_int, 401) oa_resp = authorize(req_other_account) @@ -742,9 +742,9 @@ class TestTempURL(unittest.TestCase): authorize = req.environ['swift.authorize'] oo_resp = authorize(req_other_object) - self.assertEqual(oo_resp, None) + self.assertIsNone(oo_resp) oc_resp = authorize(req_other_container) - self.assertEqual(oc_resp, None) + self.assertIsNone(oc_resp) oa_resp = authorize(req_other_account) self.assertEqual(oa_resp.status_int, 401) diff --git a/test/unit/common/test_container_sync_realms.py b/test/unit/common/test_container_sync_realms.py index 438811a168..ae487c259b 100644 --- a/test/unit/common/test_container_sync_realms.py +++ b/test/unit/common/test_container_sync_realms.py @@ -101,7 +101,7 @@ cluster_dfw1 = http://dfw1.host/v1/ self.assertEqual(csr.mtime_check_interval, 300) self.assertEqual(csr.realms(), ['US']) self.assertEqual(csr.key('US'), '9ff3b71c849749dbaec4ccdd3cbab62b') - self.assertEqual(csr.key2('US'), None) + self.assertIsNone(csr.key2('US')) self.assertEqual(csr.clusters('US'), ['DFW1']) self.assertEqual( csr.endpoint('US', 'DFW1'), 'http://dfw1.host/v1/') @@ -129,7 +129,7 @@ cluster_lon3 = http://lon3.host/v1/ self.assertEqual(csr.mtime_check_interval, 60) self.assertEqual(sorted(csr.realms()), ['UK', 'US']) self.assertEqual(csr.key('US'), '9ff3b71c849749dbaec4ccdd3cbab62b') - self.assertEqual(csr.key2('US'), None) + self.assertIsNone(csr.key2('US')) self.assertEqual(csr.clusters('US'), ['DFW1']) self.assertEqual( csr.endpoint('US', 'DFW1'), 'http://dfw1.host/v1/') @@ -152,10 +152,10 @@ cluster_lon3 = http://lon3.host/v1/ self.assertEqual(logger.all_log_lines(), {}) self.assertEqual(csr.mtime_check_interval, 300) self.assertEqual(csr.realms(), ['US']) - self.assertEqual(csr.key('US'), None) - self.assertEqual(csr.key2('US'), None) + self.assertIsNone(csr.key('US')) + self.assertIsNone(csr.key2('US')) self.assertEqual(csr.clusters('US'), []) - self.assertEqual(csr.endpoint('US', 'JUST_TESTING'), None) + self.assertIsNone(csr.endpoint('US', 'JUST_TESTING')) def test_bad_mtime_check_interval(self): fname = 'container-sync-realms.conf' diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py index 50f83c2d70..0f68195946 100644 --- a/test/unit/common/test_db_replicator.py +++ b/test/unit/common/test_db_replicator.py @@ -314,7 +314,7 @@ class TestDBReplicator(unittest.TestCase): def other_req(method, path, body, headers): raise Exception('blah') conn.request = other_req - self.assertEqual(conn.replicate(1, 2, 3), None) + self.assertIsNone(conn.replicate(1, 2, 3)) def test_rsync_file(self): replicator = TestReplicator({}) diff --git a/test/unit/common/test_direct_client.py b/test/unit/common/test_direct_client.py index 0024f114c7..75af0ea0e7 100644 --- a/test/unit/common/test_direct_client.py +++ b/test/unit/common/test_direct_client.py @@ -463,7 +463,7 @@ class TestDirectClient(unittest.TestCase): self.assertTrue('x-timestamp' in conn.req_headers) self.assertEqual('bar', conn.req_headers.get('x-foo')) - self.assertEqual(rv, None) + self.assertIsNone(rv) def test_direct_put_container_object_error(self): with mocked_http_conn(500) as conn: @@ -493,7 +493,7 @@ class TestDirectClient(unittest.TestCase): self.assertEqual(conn.method, 'DELETE') self.assertEqual(conn.path, self.obj_path) - self.assertEqual(rv, None) + self.assertIsNone(rv) def test_direct_delete_container_obj_error(self): with mocked_http_conn(500) as conn: @@ -670,7 +670,7 @@ class TestDirectClient(unittest.TestCase): self.assertEqual(conn.port, self.node['port']) self.assertEqual(conn.method, 'DELETE') self.assertEqual(conn.path, self.obj_path) - self.assertEqual(resp, None) + self.assertIsNone(resp) def test_direct_delete_object_with_timestamp(self): # ensure timestamp is different from any that might be auto-generated diff --git a/test/unit/common/test_header_key_dict.py b/test/unit/common/test_header_key_dict.py index 465bf95ccc..4ffca6083c 100644 --- a/test/unit/common/test_header_key_dict.py +++ b/test/unit/common/test_header_key_dict.py @@ -98,7 +98,7 @@ class TestHeaderKeyDict(unittest.TestCase): headers = HeaderKeyDict() headers['content-length'] = 20 self.assertEqual(headers.get('CONTENT-LENGTH'), '20') - self.assertEqual(headers.get('something-else'), None) + self.assertIsNone(headers.get('something-else')) self.assertEqual(headers.get('something-else', True), True) def test_keys(self): diff --git a/test/unit/common/test_manager.py b/test/unit/common/test_manager.py index 7eac135cb6..453c289a36 100644 --- a/test/unit/common/test_manager.py +++ b/test/unit/common/test_manager.py @@ -1122,8 +1122,8 @@ class TestServer(unittest.TestCase): expected_args = ['swift-test-server', conf2, 'verbose'] self.assertEqual(proc.args, expected_args) # assert stdout is not changed - self.assertEqual(proc.stdout, None) - self.assertEqual(proc.stderr, None) + self.assertIsNone(proc.stdout) + self.assertIsNone(proc.stderr) # test server wait server.spawn(conf3, wait=False) self.assertTrue(server.procs) @@ -1147,8 +1147,8 @@ class TestServer(unittest.TestCase): 'verbose'] self.assertEqual(proc.args, expected_args) # daemon behavior should trump wait, once shouldn't matter - self.assertEqual(proc.stdout, None) - self.assertEqual(proc.stderr, None) + self.assertIsNone(proc.stdout) + self.assertIsNone(proc.stderr) # assert pids for i, proc in enumerate(server.procs): pid_file = self.join_run_dir('test-server/%d.pid' % diff --git a/test/unit/common/test_memcached.py b/test/unit/common/test_memcached.py index 86d704c503..d3a66b6610 100644 --- a/test/unit/common/test_memcached.py +++ b/test/unit/common/test_memcached.py @@ -359,7 +359,7 @@ class TestMemcached(unittest.TestCase): self.assertEqual(mock.cache, {cache_key: ('0', '55', '5')}) memcache_client.delete('some_key') - self.assertEqual(memcache_client.get('some_key'), None) + self.assertIsNone(memcache_client.get('some_key')) fiftydays = 50 * 24 * 60 * 60 esttimeout = time.time() + fiftydays @@ -369,7 +369,7 @@ class TestMemcached(unittest.TestCase): self.assertAlmostEqual(float(cache_timeout), esttimeout, delta=1) memcache_client.delete('some_key') - self.assertEqual(memcache_client.get('some_key'), None) + self.assertIsNone(memcache_client.get('some_key')) memcache_client.incr('some_key', delta=5) self.assertEqual(memcache_client.get('some_key'), '5') @@ -418,7 +418,7 @@ class TestMemcached(unittest.TestCase): memcache_client.set('some_key', [1, 2, 3]) self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client.delete('some_key') - self.assertEqual(memcache_client.get('some_key'), None) + self.assertIsNone(memcache_client.get('some_key')) def test_multi(self): memcache_client = memcached.MemcacheRing(['1.2.3.4:11211']) @@ -470,7 +470,7 @@ class TestMemcached(unittest.TestCase): memcache_client._allow_unpickle = True self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client._allow_unpickle = False - self.assertEqual(memcache_client.get('some_key'), None) + self.assertIsNone(memcache_client.get('some_key')) memcache_client.set('some_key', [1, 2, 3]) self.assertEqual(memcache_client.get('some_key'), [1, 2, 3]) memcache_client._allow_unpickle = True diff --git a/test/unit/common/test_request_helpers.py b/test/unit/common/test_request_helpers.py index e451174516..8d8930d09c 100644 --- a/test/unit/common/test_request_helpers.py +++ b/test/unit/common/test_request_helpers.py @@ -156,7 +156,7 @@ class TestRequestHelpers(unittest.TestCase): get_name_and_placement(req, 2, 3, True) self.assertEqual(device, 'device') self.assertEqual(partition, 'part') - self.assertEqual(suffix_parts, None) # false-y + self.assertIsNone(suffix_parts) # false-y self.assertEqual(policy, POLICIES[1]) self.assertEqual(policy.policy_type, REPL_POLICY) diff --git a/test/unit/common/test_swob.py b/test/unit/common/test_swob.py index ddbe965046..53a0dac914 100644 --- a/test/unit/common/test_swob.py +++ b/test/unit/common/test_swob.py @@ -117,7 +117,7 @@ class TestRange(unittest.TestCase): swob_range = swift.common.swob.Range('bytes=1-7') self.assertEqual(swob_range.ranges_for_length(10), [(1, 8)]) self.assertEqual(swob_range.ranges_for_length(5), [(1, 5)]) - self.assertEqual(swob_range.ranges_for_length(None), None) + self.assertIsNone(swob_range.ranges_for_length(None)) def test_ranges_for_large_length(self): swob_range = swift.common.swob.Range('bytes=-100000000000000000000000') @@ -127,11 +127,11 @@ class TestRange(unittest.TestCase): swob_range = swift.common.swob.Range('bytes=1-') self.assertEqual(swob_range.ranges_for_length(10), [(1, 10)]) self.assertEqual(swob_range.ranges_for_length(5), [(1, 5)]) - self.assertEqual(swob_range.ranges_for_length(None), None) + self.assertIsNone(swob_range.ranges_for_length(None)) # This used to freak out: swob_range = swift.common.swob.Range('bytes=100-') self.assertEqual(swob_range.ranges_for_length(5), []) - self.assertEqual(swob_range.ranges_for_length(None), None) + self.assertIsNone(swob_range.ranges_for_length(None)) swob_range = swift.common.swob.Range('bytes=4-6,100-') self.assertEqual(swob_range.ranges_for_length(5), [(4, 5)]) @@ -140,7 +140,7 @@ class TestRange(unittest.TestCase): swob_range = swift.common.swob.Range('bytes=-7') self.assertEqual(swob_range.ranges_for_length(10), [(3, 10)]) self.assertEqual(swob_range.ranges_for_length(5), [(0, 5)]) - self.assertEqual(swob_range.ranges_for_length(None), None) + self.assertIsNone(swob_range.ranges_for_length(None)) swob_range = swift.common.swob.Range('bytes=4-6,-100') self.assertEqual(swob_range.ranges_for_length(5), [(4, 5), (0, 5)]) @@ -164,7 +164,7 @@ class TestRange(unittest.TestCase): self.assertEqual(swob_range.ranges_for_length(200), [(30, 151), (190, 200)]) - self.assertEqual(swob_range.ranges_for_length(None), None) + self.assertIsNone(swob_range.ranges_for_length(None)) def test_ranges_for_length_edges(self): swob_range = swift.common.swob.Range('bytes=0-1, -7') @@ -362,7 +362,7 @@ class TestAccept(unittest.TestCase): acc = swift.common.swob.Accept(accept) match = acc.best_match(['text/plain', 'application/xml', 'text/xml']) - self.assertEqual(match, None) + self.assertIsNone(match) def test_repr(self): acc = swift.common.swob.Accept("application/json") @@ -578,7 +578,7 @@ class TestRequest(unittest.TestCase): def test_bad_path_info_pop(self): req = swift.common.swob.Request.blank('blahblah') - self.assertEqual(req.path_info_pop(), None) + self.assertIsNone(req.path_info_pop()) def test_path_info_pop_last(self): req = swift.common.swob.Request.blank('/last') @@ -757,7 +757,7 @@ class TestRequest(unittest.TestCase): req.if_unmodified_since = 'something' self.assertEqual(req.headers['If-Unmodified-Since'], 'something') - self.assertEqual(req.if_unmodified_since, None) + self.assertIsNone(req.if_unmodified_since) self.assertTrue('If-Unmodified-Since' in req.headers) req.if_unmodified_since = None @@ -769,12 +769,12 @@ class TestRequest(unittest.TestCase): "%a, %d %b %Y %H:%M:%S UTC", time.struct_time(too_big_date_list)) req.if_unmodified_since = too_big_date - self.assertEqual(req.if_unmodified_since, None) + self.assertIsNone(req.if_unmodified_since) def test_bad_range(self): req = swift.common.swob.Request.blank('/hi/there', body='hi') req.range = 'bad range' - self.assertEqual(req.range, None) + self.assertIsNone(req.range) def test_accept_header(self): req = swift.common.swob.Request({'REQUEST_METHOD': 'GET', @@ -798,7 +798,7 @@ class TestRequest(unittest.TestCase): self.assertEqual(req.swift_entity_path, '/a') req = swift.common.swob.Request.blank('/v1') - self.assertEqual(req.swift_entity_path, None) + self.assertIsNone(req.swift_entity_path) def test_path_qs(self): req = swift.common.swob.Request.blank('/hi/there?hello=equal&acl') @@ -946,7 +946,7 @@ class TestRequest(unittest.TestCase): req = swift.common.swob.Request.blank( u'/', environ={'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/'}) - self.assertEqual(req.message_length(), None) + self.assertIsNone(req.message_length()) req = swift.common.swob.Request.blank( u'/', @@ -968,7 +968,7 @@ class TestRequest(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/'}, headers={'transfer-encoding': 'chunked'}, body='x' * 42) - self.assertEqual(req.message_length(), None) + self.assertIsNone(req.message_length()) req.headers['Transfer-Encoding'] = 'gzip,chunked' try: @@ -1486,7 +1486,7 @@ class TestResponse(unittest.TestCase): # app_iter exists but no body and headers resp = swift.common.swob.Response(app_iter=iter([])) - self.assertEqual(resp.content_length, None) + self.assertIsNone(resp.content_length) self.assertEqual(resp.body, '') diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 25926f2ed1..032fe2eb93 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -2428,11 +2428,11 @@ log_name = %(yarr)s''' file_name = os.path.join(t, 'blah.pid') # assert no raise self.assertEqual(os.path.exists(file_name), False) - self.assertEqual(utils.remove_file(file_name), None) + self.assertIsNone(utils.remove_file(file_name)) with open(file_name, 'w') as f: f.write('1') self.assertTrue(os.path.exists(file_name)) - self.assertEqual(utils.remove_file(file_name), None) + self.assertIsNone(utils.remove_file(file_name)) self.assertFalse(os.path.exists(file_name)) def test_human_readable(self): @@ -2977,7 +2977,7 @@ cluster_dfw1 = http://dfw1.host/v1/ def test_get_trans_id_time(self): ts = utils.get_trans_id_time('tx8c8bc884cdaf499bb29429aa9c46946e') - self.assertEqual(ts, None) + self.assertIsNone(ts) ts = utils.get_trans_id_time('tx1df4ff4f55ea45f7b2ec2-0051720c06') self.assertEqual(ts, 1366428678) self.assertEqual( @@ -2990,11 +2990,11 @@ cluster_dfw1 = http://dfw1.host/v1/ time.asctime(time.gmtime(ts)) + ' UTC', 'Sat Apr 20 03:31:18 2013 UTC') ts = utils.get_trans_id_time('') - self.assertEqual(ts, None) + self.assertIsNone(ts) ts = utils.get_trans_id_time('garbage') - self.assertEqual(ts, None) + self.assertIsNone(ts) ts = utils.get_trans_id_time('tx1df4ff4f55ea45f7b2ec2-almostright') - self.assertEqual(ts, None) + self.assertIsNone(ts) def test_config_fallocate_value(self): fallocate_value, is_percent = utils.config_fallocate_value('10%') @@ -5438,7 +5438,7 @@ class TestGreenAsyncPile(unittest.TestCase): pass pile = utils.GreenAsyncPile(3) pile.spawn(run_test) - self.assertEqual(next(pile), None) + self.assertIsNone(next(pile)) self.assertRaises(StopIteration, lambda: next(pile)) def test_waitall_timeout_timesout(self): diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index bfff77de42..696b6cc06c 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -99,13 +99,13 @@ class TestWSGI(unittest.TestCase): wsgi.monkey_patch_mimetools() sio = StringIO('blah') - self.assertEqual(mimetools.Message(sio).type, None) + self.assertIsNone(mimetools.Message(sio).type) sio = StringIO('blah') self.assertEqual(mimetools.Message(sio).plisttext, '') sio = StringIO('blah') - self.assertEqual(mimetools.Message(sio).maintype, None) + self.assertIsNone(mimetools.Message(sio).maintype) sio = StringIO('blah') - self.assertEqual(mimetools.Message(sio).subtype, None) + self.assertIsNone(mimetools.Message(sio).subtype) sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') self.assertEqual(mimetools.Message(sio).type, 'text/html') sio = StringIO('Content-Type: text/html; charset=ISO-8859-4') @@ -548,7 +548,7 @@ class TestWSGI(unittest.TestCase): self.assertEqual(sock, server_sock) self.assertTrue(isinstance(server_app, swift.proxy.server.Application)) self.assertEqual(20, server_app.client_timeout) - self.assertEqual(server_logger, None) + self.assertIsNone(server_logger) self.assertTrue('custom_pool' in kwargs) self.assertEqual(1000, kwargs['custom_pool'].size) diff --git a/test/unit/container/test_reconciler.py b/test/unit/container/test_reconciler.py index 8f5db4fb03..baef7724c6 100644 --- a/test/unit/container/test_reconciler.py +++ b/test/unit/container/test_reconciler.py @@ -362,7 +362,7 @@ class TestReconcilerUtils(unittest.TestCase): direct_head.side_effect = stub_resp_headers oldest_spi = reconciler.direct_get_container_policy_index( self.fake_ring, 'a', 'con') - self.assertEqual(oldest_spi, None) + self.assertIsNone(oldest_spi) def test_get_container_policy_index_for_deleted(self): mock_path = 'swift.container.reconciler.direct_head_container' @@ -551,7 +551,7 @@ class TestReconcilerUtils(unittest.TestCase): oldest_spi = reconciler.direct_get_container_policy_index( self.fake_ring, 'a', 'con') # expired - self.assertEqual(oldest_spi, None) + self.assertIsNone(oldest_spi) def test_direct_delete_container_entry(self): mock_path = 'swift.common.direct_client.http_connect' @@ -597,7 +597,7 @@ class TestReconcilerUtils(unittest.TestCase): mock.patch('eventlet.greenpool.DEBUG', False): rv = reconciler.direct_delete_container_entry( self.fake_ring, 'a', 'c', 'o') - self.assertEqual(rv, None) + self.assertIsNone(rv) self.assertEqual(len(mock_direct_delete.mock_calls), 3) def test_add_to_reconciler_queue(self): diff --git a/test/unit/container/test_server.py b/test/unit/container/test_server.py index eae7ba45f1..0ffe7a1f7c 100644 --- a/test/unit/container/test_server.py +++ b/test/unit/container/test_server.py @@ -260,7 +260,7 @@ class TestContainerController(unittest.TestCase): for header in ('x-container-object-count', 'x-container-bytes-used', 'x-timestamp', 'x-put-timestamp'): - self.assertEqual(resp.headers[header], None) + self.assertIsNone(resp.headers[header]) def test_deleted_headers(self): ts = (Timestamp(t).internal for t in @@ -297,7 +297,7 @@ class TestContainerController(unittest.TestCase): for header in ('x-container-object-count', 'x-container-bytes-used', 'x-timestamp', 'x-put-timestamp'): - self.assertEqual(resp.headers[header], None) + self.assertIsNone(resp.headers[header]) def test_HEAD_invalid_partition(self): req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'HEAD', @@ -2931,7 +2931,7 @@ class TestContainerController(unittest.TestCase): # Test replication_server flag was set from configuration file. container_controller = container_server.ContainerController conf = {'devices': self.testdir, 'mount_check': 'false'} - self.assertEqual(container_controller(conf).replication_server, None) + self.assertIsNone(container_controller(conf).replication_server) for val in [True, '1', 'True', 'true']: conf['replication_server'] = val self.assertTrue(container_controller(conf).replication_server) diff --git a/test/unit/container/test_sync.py b/test/unit/container/test_sync.py index 1136591ca7..f50f746ee8 100644 --- a/test/unit/container/test_sync.py +++ b/test/unit/container/test_sync.py @@ -543,7 +543,7 @@ class TestContainerSync(unittest.TestCase): # Succeeds because no rows match self.assertEqual(cs.container_failures, 1) self.assertEqual(cs.container_skips, 0) - self.assertEqual(fcb.sync_point1, None) + self.assertIsNone(fcb.sync_point1) self.assertEqual(fcb.sync_point2, -1) def fake_hash_path(account, container, obj, raw_digest=False): @@ -591,7 +591,7 @@ class TestContainerSync(unittest.TestCase): # 'deleted' key self.assertEqual(cs.container_failures, 2) self.assertEqual(cs.container_skips, 0) - self.assertEqual(fcb.sync_point1, None) + self.assertIsNone(fcb.sync_point1) self.assertEqual(fcb.sync_point2, -1) def fake_delete_object(*args, **kwargs): @@ -617,7 +617,7 @@ class TestContainerSync(unittest.TestCase): # Fails because delete_object fails self.assertEqual(cs.container_failures, 3) self.assertEqual(cs.container_skips, 0) - self.assertEqual(fcb.sync_point1, None) + self.assertIsNone(fcb.sync_point1) self.assertEqual(fcb.sync_point2, -1) fcb = FakeContainerBroker( @@ -641,7 +641,7 @@ class TestContainerSync(unittest.TestCase): # Succeeds because delete_object succeeds self.assertEqual(cs.container_failures, 3) self.assertEqual(cs.container_skips, 0) - self.assertEqual(fcb.sync_point1, None) + self.assertIsNone(fcb.sync_point1) self.assertEqual(fcb.sync_point2, 1) def test_container_second_loop(self): @@ -680,7 +680,7 @@ class TestContainerSync(unittest.TestCase): self.assertEqual(cs.container_failures, 0) self.assertEqual(cs.container_skips, 0) self.assertEqual(fcb.sync_point1, 1) - self.assertEqual(fcb.sync_point2, None) + self.assertIsNone(fcb.sync_point2) def fake_hash_path(account, container, obj, raw_digest=False): # Ensures that all rows match for second loop, ordinal is 0 and @@ -711,7 +711,7 @@ class TestContainerSync(unittest.TestCase): self.assertEqual(cs.container_failures, 1) self.assertEqual(cs.container_skips, 0) self.assertEqual(fcb.sync_point1, 1) - self.assertEqual(fcb.sync_point2, None) + self.assertIsNone(fcb.sync_point2) fcb = FakeContainerBroker( 'path', @@ -733,7 +733,7 @@ class TestContainerSync(unittest.TestCase): self.assertEqual(cs.container_failures, 1) self.assertEqual(cs.container_skips, 0) self.assertEqual(fcb.sync_point1, 1) - self.assertEqual(fcb.sync_point2, None) + self.assertIsNone(fcb.sync_point2) finally: sync.ContainerBroker = orig_ContainerBroker sync.hash_path = orig_hash_path @@ -1319,7 +1319,7 @@ class TestContainerSync(unittest.TestCase): with mock.patch('swift.container.sync.InternalClient'): cs = sync.ContainerSync( {'sync_proxy': ''}, container_ring=FakeRing()) - self.assertEqual(cs.select_http_proxy(), None) + self.assertIsNone(cs.select_http_proxy()) def test_select_http_proxy_one(self): diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index 3490ab94b6..39208df139 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -202,18 +202,18 @@ class TestDiskFileModuleMethods(unittest.TestCase): # well formatted but, unknown policy index pn = 'objects-2/0/606/198427efcff042c78606/1401379842.14643.data' - self.assertEqual(diskfile.extract_policy(pn), None) + self.assertIsNone(diskfile.extract_policy(pn)) # malformed path - self.assertEqual(diskfile.extract_policy(''), None) + self.assertIsNone(diskfile.extract_policy('')) bad_path = '/srv/node/sda1/objects-t/1/abc/def/1234.data' - self.assertEqual(diskfile.extract_policy(bad_path), None) + self.assertIsNone(diskfile.extract_policy(bad_path)) pn = 'XXXX/0/606/1984527ed42b6ef6247c78606/1401379842.14643.data' - self.assertEqual(diskfile.extract_policy(pn), None) + self.assertIsNone(diskfile.extract_policy(pn)) bad_path = '/srv/node/sda1/foo-1/1/abc/def/1234.data' - self.assertEqual(diskfile.extract_policy(bad_path), None) + self.assertIsNone(diskfile.extract_policy(bad_path)) bad_path = '/srv/node/sda1/obj1/1/abc/def/1234.data' - self.assertEqual(diskfile.extract_policy(bad_path), None) + self.assertIsNone(diskfile.extract_policy(bad_path)) def test_quarantine_renamer(self): for policy in POLICIES: @@ -4093,7 +4093,7 @@ class DiskFileMixin(BaseDiskFileTestMixin): for chunk in reader: pass # close is called at the end of the iterator - self.assertEqual(reader._fp, None) + self.assertIsNone(reader._fp) error_lines = df._logger.get_lines_for_level('error') self.assertEqual(len(error_lines), 1) self.assertIn('close failure', error_lines[0]) @@ -4716,7 +4716,7 @@ class DiskFileMixin(BaseDiskFileTestMixin): self.assertTrue(_m_mkc.called) flags = O_TMPFILE | os.O_WRONLY _m_os_open.assert_called_once_with(df._datadir, flags) - self.assertEqual(tmppath, None) + self.assertIsNone(tmppath) self.assertEqual(fd, 12345) self.assertFalse(_m_mkstemp.called) diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index 11d5fedf56..853ff12293 100644 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -4154,7 +4154,7 @@ class TestObjectController(unittest.TestCase): req = Request.blank('/sda1/p/a/c/o', method='GET') resp = req.get_response(self.object_controller) self.assertEqual(resp.status_int, 404) - self.assertEqual(resp.headers['X-Timestamp'], None) + self.assertIsNone(resp.headers['X-Timestamp']) self.assertEqual(resp.headers['X-Backend-Timestamp'], offset_delete) # and one more delete with a newer timestamp delete_timestamp = next(self.ts).internal @@ -4185,7 +4185,7 @@ class TestObjectController(unittest.TestCase): req = Request.blank('/sda1/p/a/c/o', method='GET') resp = req.get_response(self.object_controller) self.assertEqual(resp.status_int, 404) - self.assertEqual(resp.headers['X-Timestamp'], None) + self.assertIsNone(resp.headers['X-Timestamp']) self.assertEqual(resp.headers['X-Backend-Timestamp'], delete_timestamp) def test_call_bad_request(self): diff --git a/test/unit/obj/test_ssync_receiver.py b/test/unit/obj/test_ssync_receiver.py index c21d8b3588..5821f6282e 100644 --- a/test/unit/obj/test_ssync_receiver.py +++ b/test/unit/obj/test_ssync_receiver.py @@ -166,7 +166,7 @@ class TestReceiver(unittest.TestCase): [':MISSING_CHECK: START', ':MISSING_CHECK: END', ':UPDATES: START', ':UPDATES: END']) self.assertEqual(rcvr.policy, POLICIES[1]) - self.assertEqual(rcvr.frag_index, None) + self.assertIsNone(rcvr.frag_index) def test_Receiver_with_bad_storage_policy_index_header(self): valid_indices = sorted([int(policy) for policy in POLICIES]) @@ -208,7 +208,7 @@ class TestReceiver(unittest.TestCase): ':UPDATES: START', ':UPDATES: END']) self.assertEqual(rcvr.policy, POLICIES[1]) self.assertEqual(rcvr.frag_index, 7) - self.assertEqual(rcvr.node_index, None) + self.assertIsNone(rcvr.node_index) @unit.patch_policies() def test_Receiver_with_only_node_index_header(self): @@ -1517,7 +1517,7 @@ class TestReceiver(unittest.TestCase): self.assertFalse(self.controller.logger.error.called) req = _POST_request[0] self.assertEqual(req.path, '/device/partition/a/c/o') - self.assertEqual(req.content_length, None) + self.assertIsNone(req.content_length) self.assertEqual(req.headers, { 'X-Timestamp': '1364456113.12344', 'X-Object-Meta-Test1': 'one', @@ -1703,7 +1703,7 @@ class TestReceiver(unittest.TestCase): self.controller.logger.exception.assert_called_once_with( 'None/device/partition EXCEPTION in ssync.Receiver') self.assertEqual(len(_BONK_request), 1) # sanity - self.assertEqual(_BONK_request[0], None) + self.assertIsNone(_BONK_request[0]) def test_UPDATES_multiple(self): _requests = [] @@ -1865,7 +1865,7 @@ class TestReceiver(unittest.TestCase): req = _requests.pop(0) self.assertEqual(req.method, 'POST') self.assertEqual(req.path, '/device/partition/a/c/o7') - self.assertEqual(req.content_length, None) + self.assertIsNone(req.content_length) self.assertEqual(req.headers, { 'X-Timestamp': '1364456113.00008', 'X-Object-Meta-Test-User': 'user_meta',