diff options
| author | lzyeval <lzyeval@gmail.com> | 2011-12-31 12:23:56 +0800 |
|---|---|---|
| committer | lzyeval <lzyeval@gmail.com> | 2012-01-04 07:32:13 +0800 |
| commit | 88ccade9d5700db881f2ffc53e4a48a76e92c2db (patch) | |
| tree | f8da941637a68a89705ac7e717992ac8b7d44fc7 /nova/tests | |
| parent | 6f0ef4240fc42f3bf4e7b59cd83997edddb3c985 (diff) | |
PEP8 type comparison cleanup
Fixes bug #910295
The None, True, and False values are singletons.
All variable *comparisons* to singletons should use 'is' or 'is not'.
All variable *evaluations* to boolean should use 'if' or 'if not'.
"== None", "== True", "== False", and "!= None" comparisons in sqlalchemy's
where(), or_(), filter(), and_(), and select() functions should not be changed.
Incorrect comparisons or evaluations in comments were not changed.
Change-Id: I087f0883bf115b5fe714ccfda86a794b9b2a87f7
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/db/fakes.py | 4 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_distributed_scheduler.py | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/nova/tests/db/fakes.py b/nova/tests/db/fakes.py index d9bdb2351..a28d6ded0 100644 --- a/nova/tests/db/fakes.py +++ b/nova/tests/db/fakes.py @@ -102,8 +102,8 @@ def stub_out_db_network_api(stubs): networks = [network_fields] def fake_floating_ip_allocate_address(context, project_id): - ips = filter(lambda i: i['fixed_ip_id'] == None \ - and i['project_id'] == None, + ips = filter(lambda i: i['fixed_ip_id'] is None \ + and i['project_id'] is None, floating_ips) if not ips: raise exception.NoMoreFloatingIps() diff --git a/nova/tests/scheduler/test_distributed_scheduler.py b/nova/tests/scheduler/test_distributed_scheduler.py index 80781c049..047c8c51a 100644 --- a/nova/tests/scheduler/test_distributed_scheduler.py +++ b/nova/tests/scheduler/test_distributed_scheduler.py @@ -236,11 +236,11 @@ class DistributedSchedulerTestCase(test.TestCase): for weighted_host in weighted_hosts: # We set this up so remote hosts have even weights ... if int(weighted_host.weight) % 2 == 0: - self.assertTrue(weighted_host.zone != None) - self.assertTrue(weighted_host.host == None) + self.assertTrue(weighted_host.zone is not None) + self.assertTrue(weighted_host.host is None) else: - self.assertTrue(weighted_host.host != None) - self.assertTrue(weighted_host.zone == None) + self.assertTrue(weighted_host.host is not None) + self.assertTrue(weighted_host.zone is None) def test_schedule_local_zone(self): """Test to make sure _schedule makes no call out to zones if @@ -270,8 +270,8 @@ class DistributedSchedulerTestCase(test.TestCase): self.assertEquals(len(weighted_hosts), 10) for weighted_host in weighted_hosts: # There should be no remote hosts - self.assertTrue(weighted_host.host != None) - self.assertTrue(weighted_host.zone == None) + self.assertTrue(weighted_host.host is not None) + self.assertTrue(weighted_host.zone is None) def test_decrypt_blob(self): """Test that the decrypt method works.""" |
