From 8485129704f1611d13a16b7c43ab1bac46d66606 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Thu, 31 Jan 2013 13:56:42 +0800 Subject: Fixes 'not in' operator usage Change-Id: I1e26a8fcb9fa564308e63c11a72aaa55119e4eee --- nova/tests/api/openstack/fakes.py | 2 +- nova/tests/compute/test_resource_tracker.py | 2 +- nova/tests/fakeguestfs.py | 14 +++++++------- nova/tests/integrated/api/client.py | 2 +- nova/tests/integrated/integrated_helpers.py | 2 +- nova/tests/test_libvirt.py | 2 +- nova/tests/test_virt_disk_vfs_localfs.py | 10 +++++----- nova/tests/test_xenapi.py | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 03fc87ac5..857644498 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -372,7 +372,7 @@ def create_info_cache(nw_cache): def get_fake_uuid(token=0): - if not token in FAKE_UUIDS: + if token not in FAKE_UUIDS: FAKE_UUIDS[token] = str(uuid.uuid4()) return FAKE_UUIDS[token] diff --git a/nova/tests/compute/test_resource_tracker.py b/nova/tests/compute/test_resource_tracker.py index 53d92a13f..eaa0df5bf 100644 --- a/nova/tests/compute/test_resource_tracker.py +++ b/nova/tests/compute/test_resource_tracker.py @@ -391,7 +391,7 @@ class BaseTrackerTestCase(BaseTestCase): if tracker is None: tracker = self.tracker - if not field in tracker.compute_node: + if field not in tracker.compute_node: raise test.TestingException( "'%(field)s' not in compute node." % locals()) x = tracker.compute_node[field] diff --git a/nova/tests/fakeguestfs.py b/nova/tests/fakeguestfs.py index 33ca49c33..ff006db68 100644 --- a/nova/tests/fakeguestfs.py +++ b/nova/tests/fakeguestfs.py @@ -50,7 +50,7 @@ class GuestFS(object): self.mounts.append((options, device, mntpoint)) def mkdir_p(self, path): - if not path in self.files: + if path not in self.files: self.files[path] = { "isdir": True, "gid": 100, @@ -59,7 +59,7 @@ class GuestFS(object): } def read_file(self, path): - if not path in self.files: + if path not in self.files: self.files[path] = { "isdir": False, "content": "Hello World", @@ -71,7 +71,7 @@ class GuestFS(object): return self.files[path]["content"] def write(self, path, content): - if not path in self.files: + if path not in self.files: self.files[path] = { "isdir": False, "content": "Hello World", @@ -83,7 +83,7 @@ class GuestFS(object): self.files[path]["content"] = content def write_append(self, path, content): - if not path in self.files: + if path not in self.files: self.files[path] = { "isdir": False, "content": "Hello World", @@ -95,13 +95,13 @@ class GuestFS(object): self.files[path]["content"] = self.files[path]["content"] + content def stat(self, path): - if not path in self.files: + if path not in self.files: raise RuntimeError("No such file: " + path) return self.files[path]["mode"] def chown(self, uid, gid, path): - if not path in self.files: + if path not in self.files: raise RuntimeError("No such file: " + path) if uid != -1: @@ -110,7 +110,7 @@ class GuestFS(object): self.files[path]["gid"] = gid def chmod(self, mode, path): - if not path in self.files: + if path not in self.files: raise RuntimeError("No such file: " + path) self.files[path]["mode"] = mode diff --git a/nova/tests/integrated/api/client.py b/nova/tests/integrated/api/client.py index a072b3128..958a5500b 100644 --- a/nova/tests/integrated/api/client.py +++ b/nova/tests/integrated/api/client.py @@ -155,7 +155,7 @@ class TestOpenStackClient(object): LOG.debug(_("%(relative_uri)s => code %(http_status)s") % locals()) if check_response_status: - if not http_status in check_response_status: + if http_status not in check_response_status: if http_status == 404: raise OpenStackApiNotFoundException(response=response) elif http_status == 401: diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index f17dc025f..90e9a806e 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -58,7 +58,7 @@ def generate_new_element(items, prefix, numeric=False): candidate = prefix + generate_random_numeric(8) else: candidate = prefix + generate_random_alphanumeric(8) - if not candidate in items: + if candidate not in items: return candidate LOG.debug("Random collision on %s" % candidate) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 72c886529..6e7986b0e 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -3848,7 +3848,7 @@ class IptablesFirewallTestCase(test.TestCase): in_rules = filter(lambda l: not l.startswith('#'), self.in_rules) for rule in in_rules: - if not 'nova' in rule: + if 'nova' not in rule: self.assertTrue(rule in self.out_rules, 'Rule went missing: %s' % rule) diff --git a/nova/tests/test_virt_disk_vfs_localfs.py b/nova/tests/test_virt_disk_vfs_localfs.py index af4571dd2..096a75964 100644 --- a/nova/tests/test_virt_disk_vfs_localfs.py +++ b/nova/tests/test_virt_disk_vfs_localfs.py @@ -46,7 +46,7 @@ def fake_execute(*args, **kwargs): elif args[0] == "chown": owner = args[1] path = args[2] - if not path in files: + if path not in files: raise Exception("No such file: " + path) sep = owner.find(':') @@ -72,7 +72,7 @@ def fake_execute(*args, **kwargs): elif args[0] == "chgrp": group = args[1] path = args[2] - if not path in files: + if path not in files: raise Exception("No such file: " + path) if group == "users": @@ -83,13 +83,13 @@ def fake_execute(*args, **kwargs): elif args[0] == "chmod": mode = args[1] path = args[2] - if not path in files: + if path not in files: raise Exception("No such file: " + path) files[path]["mode"] = int(mode, 8) elif args[0] == "cat": path = args[1] - if not path in files: + if path not in files: files[path] = { "content": "Hello World", "gid": 100, @@ -104,7 +104,7 @@ def fake_execute(*args, **kwargs): else: path = args[1] append = False - if not path in files: + if path not in files: files[path] = { "content": "Hello World", "gid": 100, diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index aa640810b..c480d5c5f 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -595,7 +595,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): def _check_vdis(self, start_list, end_list): for vdi_ref in end_list: - if not vdi_ref in start_list: + if vdi_ref not in start_list: vdi_rec = xenapi_fake.get_record('VDI', vdi_ref) # If the cache is turned on then the base disk will be # there even after the cleanup @@ -1949,7 +1949,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase): in_rules = filter(lambda l: not l.startswith('#'), self._in_rules) for rule in in_rules: - if not 'nova' in rule: + if 'nova' not in rule: self.assertTrue(rule in self._out_rules, 'Rule went missing: %s' % rule) -- cgit