diff --git a/swift/common/utils.py b/swift/common/utils.py index a34e7b3ae1..12aa12f1c9 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -852,7 +852,7 @@ def write_pickle(obj, dest, tmp=None, pickle_protocol=0): :param tmp: path to tmp to use, defaults to None :param pickle_protocol: protocol to pickle the obj with, defaults to 0 """ - if tmp == None: + if tmp is None: tmp = os.path.dirname(dest) fd, tmppath = mkstemp(dir=tmp, suffix='.tmp') with os.fdopen(fd, 'wb') as fo: diff --git a/swift/obj/server.py b/swift/obj/server.py index 3f692f637d..f6315071fc 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -644,7 +644,7 @@ class ObjectController(object): file.metadata['ETag'] not in request.if_match: file.close() return HTTPPreconditionFailed(request=request) - if request.headers.get('if-none-match') != None: + if request.headers.get('if-none-match') is not None: if file.metadata['ETag'] in request.if_none_match: resp = HTTPNotModified(request=request) resp.etag = file.metadata['ETag'] diff --git a/test/functional/swift.py b/test/functional/swift.py index c9180e68da..878c276241 100644 --- a/test/functional/swift.py +++ b/test/functional/swift.py @@ -321,7 +321,7 @@ class Account(Base): format = parms.get('format', None) if format not in [None, 'json', 'xml']: raise RequestError('Invalid format: %s' % format) - if format == None and parms.has_key('format'): + if format is None and parms.has_key('format'): del parms['format'] status = self.conn.make_request('GET', self.path, hdrs=hdrs, @@ -410,7 +410,7 @@ class Container(Base): format = parms.get('format', None) if format not in [None, 'json', 'xml']: raise RequestError('Invalid format: %s' % format) - if format == None and parms.has_key('format'): + if format is None and parms.has_key('format'): del parms['format'] status = self.conn.make_request('GET', self.path, hdrs=hdrs, @@ -591,7 +591,7 @@ class File(Base): @classmethod def random_data(cls, size=None): - if size == None: + if size is None: size = random.randint(1, 32768) fd = open('/dev/urandom', 'r') data = fd.read(size) @@ -674,9 +674,9 @@ class File(Base): return True def chunked_write(self, data=None, hdrs={}, parms={}, cfg={}): - if data != None and self.chunked_write_in_progress: + if data is not None and self.chunked_write_in_progress: self.conn.put_data(data, True) - elif data != None: + elif data is not None: self.chunked_write_in_progress = True headers = self.make_headers(cfg=cfg) diff --git a/test/functional/tests.py b/test/functional/tests.py index 4490dcf01b..8f89918849 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -81,7 +81,7 @@ class Utils: @classmethod def create_utf8_name(cls, length=None): - if length == None: + if length is None: length = 15 else: length = int(length) @@ -271,7 +271,7 @@ class TestAccount(Base): containers = self.env.account.containers( parms={'format':format,'marker':containers[-1]}) self.assertEquals(len(containers), 0) - if format == None: + if format is None: self.assert_status(204) else: self.assert_status(200) @@ -320,7 +320,7 @@ class TestAccountNoContainers(Base): self.assert_(not self.env.account.containers( parms={'format':format})) - if format == None: + if format is None: self.assert_status(204) else: self.assert_status(200) @@ -529,7 +529,7 @@ class TestContainer(Base): parms={'format':format,'marker':files[-1]}) self.assertEquals(len(files), 0) - if format == None: + if format is None: self.assert_status(204) else: self.assert_status(200) diff --git a/test/unit/__init__.py b/test/unit/__init__.py index f33c295a51..345931285f 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -145,6 +145,6 @@ class MockTrue(object): def __repr__(*args, **kwargs): return repr(True) def __eq__(self, other): - return other == True + return other is True def __ne__(self, other): - return other != True + return other is not True diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index 94dfdad0e7..48b02d9480 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -607,7 +607,7 @@ class TestContainerBroker(unittest.TestCase): raise Exception('OMG') except Exception: pass - self.assert_(broker.conn == None) + self.assert_(broker.conn is None) def test_empty(self): """ Test swift.common.db.ContainerBroker.empty """ @@ -1535,7 +1535,7 @@ class TestAccountBroker(unittest.TestCase): raise Exception('OMG') except Exception: pass - self.assert_(broker.conn == None) + self.assert_(broker.conn is None) def test_empty(self): """ Test swift.common.db.AccountBroker.empty """ diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 39d01cbf02..46e100bc82 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -483,7 +483,7 @@ class TestController(unittest.TestCase): cache_key = proxy_server.get_container_memcache_key(self.account, self.container) cache_value = self.memcache.get(cache_key) - self.assertEquals(dict, type(cache_value)) + self.assertTrue(isinstance(cache_value, dict)) self.assertEquals(200, cache_value.get('status')) proxy_server.http_connect = fake_http_connect() @@ -506,7 +506,7 @@ class TestController(unittest.TestCase): cache_key = proxy_server.get_container_memcache_key(self.account, self.container) cache_value = self.memcache.get(cache_key) - self.assertEquals(dict, type(cache_value)) + self.assertTrue(isinstance(cache_value, dict)) self.assertEquals(404, cache_value.get('status')) proxy_server.http_connect = fake_http_connect()