From fd7f84b20b30b15445725c39bc5f8b1218de25d4 Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Mon, 5 Oct 2015 23:55:52 +0200 Subject: [PATCH] Use assertIsNone(observed) instead of assertEqual(None, observed) Neutron should use the specific assertion: self.assertIsNone(observed) instead of the generic assertion: self.assertEqual(None, observed) as it raises more specific errors. Closes-Bug: #1503055 Change-Id: Ib7e5875bd0a95320d89a7504f951998fb210acc1 --- neutron/tests/api/test_networks.py | 2 +- neutron/tests/unit/agent/common/test_ovs_lib.py | 2 +- neutron/tests/unit/agent/l3/test_agent.py | 2 +- neutron/tests/unit/agent/l3/test_dvr_local_router.py | 2 +- neutron/tests/unit/extensions/test_vlantransparent.py | 2 +- neutron/tests/unit/ipam/test_requests.py | 8 ++++---- neutron/tests/unit/notifiers/test_nova.py | 2 +- .../linuxbridge/agent/test_linuxbridge_neutron_agent.py | 3 +-- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/neutron/tests/api/test_networks.py b/neutron/tests/api/test_networks.py index 868c08d7c67..aaf5274c386 100644 --- a/neutron/tests/api/test_networks.py +++ b/neutron/tests/api/test_networks.py @@ -591,7 +591,7 @@ class NetworksIpV6TestJSON(NetworksTestJSON): # Verifies Subnet GW is set in IPv6 self.assertEqual(subnet1['gateway_ip'], ipv6_gateway) # Verifies Subnet GW is None in IPv4 - self.assertEqual(subnet2['gateway_ip'], None) + self.assertIsNone(subnet2['gateway_ip']) # Verifies all 2 subnets in the same network body = self.client.list_subnets() subnets = [sub['id'] for sub in body['subnets'] diff --git a/neutron/tests/unit/agent/common/test_ovs_lib.py b/neutron/tests/unit/agent/common/test_ovs_lib.py index 8741dff79d2..5efc2979d2a 100644 --- a/neutron/tests/unit/agent/common/test_ovs_lib.py +++ b/neutron/tests/unit/agent/common/test_ovs_lib.py @@ -324,7 +324,7 @@ class OVS_Lib_Test(base.BaseTestCase): run_ofctl = mock.patch.object(self.br, 'run_ofctl').start() run_ofctl.side_effect = [''] retflows = self.br.dump_flows_for_table(table) - self.assertEqual(None, retflows) + self.assertIsNone(retflows) def test_mod_flow_with_priority_set(self): params = {'in_port': '1', diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index ea9409917c5..90e09f3c833 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -210,7 +210,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): report_state.assert_called_once_with(agent.context, agent.agent_state, use_call_arg) - self.assertTrue(agent.agent_state.get('start_flag') is None) + self.assertIsNone(agent.agent_state.get('start_flag')) def test_periodic_sync_routers_task_call_clean_stale_namespaces(self): agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) diff --git a/neutron/tests/unit/agent/l3/test_dvr_local_router.py b/neutron/tests/unit/agent/l3/test_dvr_local_router.py index 06175302b59..048beb305e7 100644 --- a/neutron/tests/unit/agent/l3/test_dvr_local_router.py +++ b/neutron/tests/unit/agent/l3/test_dvr_local_router.py @@ -303,7 +303,7 @@ class TestDvrRouterOperations(base.BaseTestCase): port = {'fixed_ips': [{'subnet_id': mock.sentinel.subnet_id}]} router_ports = [port] ri.router.get.return_value = router_ports - self.assertEqual(None, ri._get_internal_port(mock.sentinel.subnet_id2)) + self.assertIsNone(ri._get_internal_port(mock.sentinel.subnet_id2)) def test__get_snat_idx_ipv4(self): ip_cidr = '101.12.13.00/24' diff --git a/neutron/tests/unit/extensions/test_vlantransparent.py b/neutron/tests/unit/extensions/test_vlantransparent.py index de9c03e0630..717d306b70c 100644 --- a/neutron/tests/unit/extensions/test_vlantransparent.py +++ b/neutron/tests/unit/extensions/test_vlantransparent.py @@ -102,4 +102,4 @@ class VlanTransparentExtensionTestCase(test_db_base_plugin_v2.TestNetworksV2): res = self.deserialize(self.fmt, req.get_response(self.api)) self.assertEqual(net['network']['name'], res['network']['name']) - self.assertEqual(None, res['network'][vlt.VLANTRANSPARENT]) + self.assertIsNone(res['network'][vlt.VLANTRANSPARENT]) diff --git a/neutron/tests/unit/ipam/test_requests.py b/neutron/tests/unit/ipam/test_requests.py index e15f3a7f4e1..20efc448b4b 100644 --- a/neutron/tests/unit/ipam/test_requests.py +++ b/neutron/tests/unit/ipam/test_requests.py @@ -43,8 +43,8 @@ class TestIpamSubnetRequests(IpamSubnetRequestTestCase): self.subnet_id) self.assertEqual(self.tenant_id, pool.tenant_id) self.assertEqual(self.subnet_id, pool.subnet_id) - self.assertEqual(None, pool.gateway_ip) - self.assertEqual(None, pool.allocation_pools) + self.assertIsNone(pool.gateway_ip) + self.assertIsNone(pool.allocation_pools) def test_subnet_request_gateway(self): request = ipam_req.SubnetRequest(self.tenant_id, @@ -364,8 +364,8 @@ class TestSubnetRequestFactory(IpamSubnetRequestTestCase): ipam_req.SpecificSubnetRequest) self.assertEqual(self.tenant_id, request.tenant_id) self.assertEqual(self.subnet_id, request.subnet_id) - self.assertEqual(None, request.gateway_ip) - self.assertEqual(None, request.allocation_pools) + self.assertIsNone(request.gateway_ip) + self.assertIsNone(request.allocation_pools) class TestGetRequestFactory(base.BaseTestCase): diff --git a/neutron/tests/unit/notifiers/test_nova.py b/neutron/tests/unit/notifiers/test_nova.py index 0bb9693645c..6f6a24b8c58 100644 --- a/neutron/tests/unit/notifiers/test_nova.py +++ b/neutron/tests/unit/notifiers/test_nova.py @@ -178,7 +178,7 @@ class TestNovaNotify(base.BaseTestCase): event = self.nova_notifier.create_port_changed_event( 'delete_floatingip', {}, returned_obj) - self.assertEqual(event, None) + self.assertIsNone(event) def test_associate_floatingip_notify(self): device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87' diff --git a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py index 55a09e521a0..7c8c3a1278c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py @@ -385,8 +385,7 @@ class TestLinuxBridgeManager(base.BaseTestCase): self.lbm.get_existing_bridge_name(phy_net)) phy_net = '' - self.assertEqual(None, - self.lbm.get_existing_bridge_name(phy_net)) + self.assertIsNone(self.lbm.get_existing_bridge_name(phy_net)) def test_get_bridge_name(self): nw_id = "123456789101112"