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
This commit is contained in:
Cedric Brandily 2015-10-05 23:55:52 +02:00
parent 49746ca474
commit fd7f84b20b
8 changed files with 11 additions and 12 deletions

View File

@ -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']

View File

@ -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',

View File

@ -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)

View File

@ -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'

View File

@ -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])

View File

@ -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):

View File

@ -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'

View File

@ -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"