From 3be9a973806c40c2a8187bc457ccc918f1a47a25 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Wed, 9 Oct 2013 09:44:01 +0800 Subject: [PATCH] Utilizes assertIsNone and assertIsNotNone Using assertEqual/assertNotEqual to test if an element is or is not None is too python2.4. Our unit testing framework supports assertIsNone and assertIsNotNone which were created for these types of tests. Partial-bug: #1230028 Change-Id: Ie0bddae642f7973ee8b0e00164415f8d87de387e --- .../unit/db/firewall/test_db_firewall.py | 2 +- .../unit/linuxbridge/test_lb_neutron_agent.py | 5 ++-- .../linuxbridge/test_lb_security_group.py | 2 +- .../drivers/test_arista_mechanism_driver.py | 2 +- neutron/tests/unit/ml2/test_security_group.py | 2 +- neutron/tests/unit/ml2/test_type_gre.py | 4 ++-- neutron/tests/unit/ml2/test_type_vxlan.py | 2 +- .../unit/mlnx/test_mlnx_security_group.py | 2 +- neutron/tests/unit/nec/test_db.py | 24 +++++++++---------- .../tests/unit/nicira/test_nicira_plugin.py | 4 ++-- .../openvswitch/test_ovs_security_group.py | 2 +- .../tests/unit/ryu/test_ryu_security_group.py | 2 +- neutron/tests/unit/test_api_v2_resource.py | 8 +++---- neutron/tests/unit/test_attributes.py | 2 +- neutron/tests/unit/test_common_utils.py | 12 +++++----- neutron/tests/unit/test_config.py | 2 +- neutron/tests/unit/test_db_plugin.py | 5 ++-- .../tests/unit/test_extension_ext_gw_mode.py | 2 +- .../tests/unit/test_extension_extraroute.py | 2 +- neutron/tests/unit/test_l3_plugin.py | 19 +++++++-------- neutron/tests/unit/test_linux_ip_lib.py | 2 +- .../tests/unit/test_routerserviceinsertion.py | 2 +- 22 files changed, 53 insertions(+), 56 deletions(-) diff --git a/neutron/tests/unit/db/firewall/test_db_firewall.py b/neutron/tests/unit/db/firewall/test_db_firewall.py index 7632a8da4b..5a862f6afe 100644 --- a/neutron/tests/unit/db/firewall/test_db_firewall.py +++ b/neutron/tests/unit/db/firewall/test_db_firewall.py @@ -528,7 +528,7 @@ class TestFirewallDBPlugin(FirewallPluginDbTestCase): self.plugin.get_firewall_policy, ctx, fwp_id) fw_rule = self.plugin.get_firewall_rule(ctx, fr_id) - self.assertEqual(fw_rule['firewall_policy_id'], None) + self.assertIsNone(fw_rule['firewall_policy_id']) def test_delete_firewall_policy_with_firewall_association(self): attrs = self._get_test_firewall_attrs() diff --git a/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py b/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py index ba76786603..ce183f6454 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py +++ b/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py @@ -209,7 +209,7 @@ class TestLinuxBridgeManager(base.BaseTestCase): vn_id = constants.MAX_VXLAN_VNI self.assertEqual(self.lbm.get_vxlan_device_name(vn_id), "vxlan-" + str(vn_id)) - self.assertEqual(self.lbm.get_vxlan_device_name(vn_id + 1), None) + self.assertIsNone(self.lbm.get_vxlan_device_name(vn_id + 1)) def test_get_all_neutron_bridges(self): br_list = ["br-int", "brq1", "brq2", "br-ex"] @@ -256,8 +256,7 @@ class TestLinuxBridgeManager(base.BaseTestCase): get_if_fn.return_value = ["tap1", "tap2", "tap3"] self.assertEqual(self.lbm.get_bridge_for_tap_device("tap1"), "br-int") - self.assertEqual(self.lbm.get_bridge_for_tap_device("tap4"), - None) + self.assertIsNone(self.lbm.get_bridge_for_tap_device("tap4")) def test_is_device_on_bridge(self): self.assertTrue(not self.lbm.is_device_on_bridge("")) diff --git a/neutron/tests/unit/linuxbridge/test_lb_security_group.py b/neutron/tests/unit/linuxbridge/test_lb_security_group.py index 8268710d02..e26636d90f 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_security_group.py +++ b/neutron/tests/unit/linuxbridge/test_lb_security_group.py @@ -95,7 +95,7 @@ class TestLinuxBridgeSecurityGroupsDB(LinuxBridgeSecurityGroupsTestCase): def test_security_group_get_port_from_device_with_no_port(self): port_dict = lb_db.get_port_from_device('bad_device_id') - self.assertEqual(None, port_dict) + self.assertIsNone(port_dict) class TestLinuxBridgeSecurityGroupsDBXML(TestLinuxBridgeSecurityGroupsDB): diff --git a/neutron/tests/unit/ml2/drivers/test_arista_mechanism_driver.py b/neutron/tests/unit/ml2/drivers/test_arista_mechanism_driver.py index e1f5514623..2eac54b778 100644 --- a/neutron/tests/unit/ml2/drivers/test_arista_mechanism_driver.py +++ b/neutron/tests/unit/ml2/drivers/test_arista_mechanism_driver.py @@ -218,7 +218,7 @@ class PositiveRPCWrapperValidConfigTestCase(base.BaseTestCase): self.drv._server = mock.MagicMock() def test_no_exception_on_correct_configuration(self): - self.assertNotEqual(self.drv, None) + self.assertIsNotNone(self.drv) def test_plug_host_into_network(self): tenant_id = 'ten-1' diff --git a/neutron/tests/unit/ml2/test_security_group.py b/neutron/tests/unit/ml2/test_security_group.py index 7e041027de..ff0bc39f5e 100644 --- a/neutron/tests/unit/ml2/test_security_group.py +++ b/neutron/tests/unit/ml2/test_security_group.py @@ -82,7 +82,7 @@ class TestMl2SecurityGroups(Ml2SecurityGroupsTestCase, def test_security_group_get_port_from_device_with_no_port(self): plugin = manager.NeutronManager.get_plugin() port_dict = plugin.callbacks.get_port_from_device('bad_device_id') - self.assertEqual(None, port_dict) + self.assertIsNone(port_dict) class TestMl2SecurityGroupsXML(TestMl2SecurityGroups): diff --git a/neutron/tests/unit/ml2/test_type_gre.py b/neutron/tests/unit/ml2/test_type_gre.py index 51516ed515..e17f337eab 100644 --- a/neutron/tests/unit/ml2/test_type_gre.py +++ b/neutron/tests/unit/ml2/test_type_gre.py @@ -133,7 +133,7 @@ class GreTypeTest(base.BaseTestCase): self.driver.release_segment(self.session, segment) alloc = self.driver.get_gre_allocation(self.session, segment[api.SEGMENTATION_ID]) - self.assertEqual(None, alloc) + self.assertIsNone(alloc) def test_allocate_tenant_segment(self): tunnel_ids = set() @@ -146,7 +146,7 @@ class GreTypeTest(base.BaseTestCase): tunnel_ids.add(segment[api.SEGMENTATION_ID]) segment = self.driver.allocate_tenant_segment(self.session) - self.assertEqual(None, segment) + self.assertIsNone(segment) segment = {api.NETWORK_TYPE: 'gre', api.PHYSICAL_NETWORK: 'None', diff --git a/neutron/tests/unit/ml2/test_type_vxlan.py b/neutron/tests/unit/ml2/test_type_vxlan.py index 7f4fd8baaa..daf53a339b 100644 --- a/neutron/tests/unit/ml2/test_type_vxlan.py +++ b/neutron/tests/unit/ml2/test_type_vxlan.py @@ -155,7 +155,7 @@ class VxlanTypeTest(base.BaseTestCase): tunnel_ids.add(segment[api.SEGMENTATION_ID]) segment = self.driver.allocate_tenant_segment(self.session) - self.assertEqual(None, segment) + self.assertIsNone(segment) segment = {api.NETWORK_TYPE: 'vxlan', api.PHYSICAL_NETWORK: 'None', diff --git a/neutron/tests/unit/mlnx/test_mlnx_security_group.py b/neutron/tests/unit/mlnx/test_mlnx_security_group.py index 9305241613..9e0a890f4b 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_security_group.py +++ b/neutron/tests/unit/mlnx/test_mlnx_security_group.py @@ -96,7 +96,7 @@ class TestMlnxSecurityGroupsDB(MlnxSecurityGroupsTestCase): def test_security_group_get_port_from_device_with_no_port(self): port_dict = mlnx_db.get_port_from_device('bad_device_id') - self.assertEqual(None, port_dict) + self.assertIsNone(port_dict) class TestMlnxSecurityGroupsDBXML(TestMlnxSecurityGroupsDB): diff --git a/neutron/tests/unit/nec/test_db.py b/neutron/tests/unit/nec/test_db.py index 233284532d..0c1909c4c2 100644 --- a/neutron/tests/unit/nec/test_db.py +++ b/neutron/tests/unit/nec/test_db.py @@ -77,7 +77,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): self.assertEqual(tenant.quantum_id, q) tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n) - self.assertEqual(None, tenant_none) + self.assertIsNone(tenant_none) def testb_get_ofc_id(self): """test get OFC d.""" @@ -87,7 +87,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): self.assertEqual(tenant_id, o) tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n) - self.assertEqual(None, tenant_none) + self.assertIsNone(tenant_none) def testb_exists_ofc_item(self): """test get OFC d.""" @@ -97,7 +97,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): self.assertTrue(ret) tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n) - self.assertEqual(None, tenant_none) + self.assertIsNone(tenant_none) def testc_find_ofc_item(self): """test find OFC item.""" @@ -108,7 +108,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): self.assertEqual(tenant.quantum_id, q) tenant_none = ndb.find_ofc_item(self.session, 'ofc_tenant', n) - self.assertEqual(None, tenant_none) + self.assertIsNone(tenant_none) def testc_del_ofc_item(self): """test delete OFC item.""" @@ -118,10 +118,10 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', q) - self.assertEqual(None, tenant_none) + self.assertIsNone(tenant_none) tenant_none = ndb.find_ofc_item(self.session, 'ofc_tenant', o) - self.assertEqual(None, tenant_none) + self.assertIsNone(tenant_none) def _compare_portinfo(self, portinfo, expected): self.assertEqual(portinfo.id, expected['port_id']) @@ -157,7 +157,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): nonexist_id = uuidutils.generate_uuid() portinfo_none = ndb.get_portinfo(self.session, nonexist_id) - self.assertEqual(None, portinfo_none) + self.assertIsNone(portinfo_none) def testf_del_portinfo(self): """test delete portinfo.""" @@ -167,7 +167,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase): self.assertEqual(portinfo.id, params['port_id']) ndb.del_portinfo(self.session, params['port_id']) portinfo_none = ndb.get_portinfo(self.session, params['port_id']) - self.assertEqual(None, portinfo_none) + self.assertIsNone(portinfo_none) class NECPluginV2DBOldMappingTest(NECPluginV2DBTestBase): @@ -187,7 +187,7 @@ class NECPluginV2DBOldMappingTest(NECPluginV2DBTestBase): self.assertEqual(ret.ofc_id, o) self.assertEqual(ret.quantum_id, q) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD) - self.assertEqual(ret, None) + self.assertIsNone(ret) def test_add_ofc_item_old(self): o, q, n = self.get_ofc_item_random_params() @@ -196,7 +196,7 @@ class NECPluginV2DBOldMappingTest(NECPluginV2DBTestBase): self.assertEqual(ret.quantum_id, q) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW) - self.assertEqual(ret, None) + self.assertIsNone(ret) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD) self.assertEqual(ret.id, o) self.assertEqual(ret.quantum_id, q) @@ -260,9 +260,9 @@ class NECPluginV2DBOldMappingTest(NECPluginV2DBTestBase): ndb.del_ofc_item(self.session, 'ofc_tenant', q, mode) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW) - self.assertEqual(ret, None) + self.assertIsNone(ret) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD) - self.assertEqual(ret, None) + self.assertIsNone(ret) def test_delete_ofc_item_new(self): self._check_delete_ofc_item(self.NEW) diff --git a/neutron/tests/unit/nicira/test_nicira_plugin.py b/neutron/tests/unit/nicira/test_nicira_plugin.py index dbbbf8f1d1..a7f8836d5d 100644 --- a/neutron/tests/unit/nicira/test_nicira_plugin.py +++ b/neutron/tests/unit/nicira/test_nicira_plugin.py @@ -1017,7 +1017,7 @@ class TestNiciraQoSQueue(NiciraPluginV2TestCase): return_value={"uuid": "fake_queue"}): with self.qos_queue(name='fake_lqueue', min=34, max=44, qos_marking='trusted', default=False) as q: - self.assertEqual(q['qos_queue']['dscp'], None) + self.assertIsNone(q['qos_queue']['dscp']) self.assertTrue(log.called) def test_create_qos_queue_name_exceeds_40_chars(self): @@ -1113,7 +1113,7 @@ class TestNiciraQoSQueue(NiciraPluginV2TestCase): device_id = "00fff4d0-e4a8-4a3a-8906-4c4cdafb59f1" res = self._create_port('json', net1['network']['id']) port = self.deserialize('json', res) - self.assertEqual(port['port'][ext_qos.QUEUE], None) + self.assertIsNone(port['port'][ext_qos.QUEUE]) data = {'port': {'device_id': device_id}} req = self.new_update_request('ports', data, diff --git a/neutron/tests/unit/openvswitch/test_ovs_security_group.py b/neutron/tests/unit/openvswitch/test_ovs_security_group.py index 5985ae23e4..0ce3ee009b 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_security_group.py +++ b/neutron/tests/unit/openvswitch/test_ovs_security_group.py @@ -99,7 +99,7 @@ class TestOpenvswitchSecurityGroups(OpenvswitchSecurityGroupsTestCase, def test_security_group_get_port_from_device_with_no_port(self): plugin = manager.NeutronManager.get_plugin() port_dict = plugin.callbacks.get_port_from_device('bad_device_id') - self.assertEqual(None, port_dict) + self.assertIsNone(port_dict) class TestOpenvswitchSecurityGroupsXML(TestOpenvswitchSecurityGroups): diff --git a/neutron/tests/unit/ryu/test_ryu_security_group.py b/neutron/tests/unit/ryu/test_ryu_security_group.py index 01d764eb8f..65c5d92880 100644 --- a/neutron/tests/unit/ryu/test_ryu_security_group.py +++ b/neutron/tests/unit/ryu/test_ryu_security_group.py @@ -91,7 +91,7 @@ class TestRyuSecurityGroups(RyuSecurityGroupsTestCase, def test_security_group_get_port_from_device_with_no_port(self): plugin = manager.NeutronManager.get_plugin() port_dict = plugin.callbacks.get_port_from_device('bad_device_id') - self.assertEqual(None, port_dict) + self.assertIsNone(port_dict) class TestRyuSecurityGroupsXML(TestRyuSecurityGroups): diff --git a/neutron/tests/unit/test_api_v2_resource.py b/neutron/tests/unit/test_api_v2_resource.py index 564a01c4ce..83e8bfa3d3 100644 --- a/neutron/tests/unit/test_api_v2_resource.py +++ b/neutron/tests/unit/test_api_v2_resource.py @@ -38,7 +38,7 @@ class RequestTestCase(base.BaseTestCase): def test_content_type_missing(self): request = wsgi.Request.blank('/tests/123', method='POST') request.body = "" - self.assertEqual(None, request.get_content_type()) + self.assertIsNone(request.get_content_type()) def test_content_type_with_charset(self): request = wsgi.Request.blank('/tests/123') @@ -113,13 +113,13 @@ class RequestTestCase(base.BaseTestCase): # the best match locale should be None request.headers['Accept-Language'] = 'unknown-language' language = request.best_match_language() - self.assertEqual(language, None) + self.assertIsNone(language) request.headers['Accept-Language'] = '' language = request.best_match_language() - self.assertEqual(language, None) + self.assertIsNone(language) request.headers.pop('Accept-Language') language = request.best_match_language() - self.assertEqual(language, None) + self.assertIsNone(language) class ResourceTestCase(base.BaseTestCase): diff --git a/neutron/tests/unit/test_attributes.py b/neutron/tests/unit/test_attributes.py index a763b54d17..7600517d0a 100644 --- a/neutron/tests/unit/test_attributes.py +++ b/neutron/tests/unit/test_attributes.py @@ -508,7 +508,7 @@ class TestAttributes(base.BaseTestCase): 'f3eeab00-8367-4524-b662-55e64d4cacb5']] for uuid_list in valid_uuid_lists: msg = attributes._validate_uuid_list(uuid_list) - self.assertEqual(msg, None) + self.assertIsNone(msg) def test_validate_dict_type(self): for value in (None, True, '1', []): diff --git a/neutron/tests/unit/test_common_utils.py b/neutron/tests/unit/test_common_utils.py index 4fa2719455..364d3ed210 100644 --- a/neutron/tests/unit/test_common_utils.py +++ b/neutron/tests/unit/test_common_utils.py @@ -100,12 +100,12 @@ class TestVlanRangeVerifyValid(UtilTestParseVlanRanges): return plugin_utils.verify_vlan_range(vlan_range) def test_range_valid_ranges(self): - self.assertEqual(self.verify_range((1, 2)), None) - self.assertEqual(self.verify_range((1, 1999)), None) - self.assertEqual(self.verify_range((100, 100)), None) - self.assertEqual(self.verify_range((100, 200)), None) - self.assertEqual(self.verify_range((4001, 4094)), None) - self.assertEqual(self.verify_range((1, 4094)), None) + self.assertIsNone(self.verify_range((1, 2))) + self.assertIsNone(self.verify_range((1, 1999))) + self.assertIsNone(self.verify_range((100, 100))) + self.assertIsNone(self.verify_range((100, 200))) + self.assertIsNone(self.verify_range((4001, 4094))) + self.assertIsNone(self.verify_range((1, 4094))) def check_one_vlan_invalid(self, bad_range, which): expected_msg = self._vrange_invalid_vlan(bad_range, which) diff --git a/neutron/tests/unit/test_config.py b/neutron/tests/unit/test_config.py index 1b1e9929a8..4a93ed6fed 100644 --- a/neutron/tests/unit/test_config.py +++ b/neutron/tests/unit/test_config.py @@ -31,7 +31,7 @@ class ConfigurationTest(base.BaseTestCase): self.assertEqual('', cfg.CONF.api_extensions_path) self.assertEqual('policy.json', cfg.CONF.policy_file) self.assertEqual('keystone', cfg.CONF.auth_strategy) - self.assertEqual(None, cfg.CONF.core_plugin) + self.assertIsNone(cfg.CONF.core_plugin) self.assertEqual(0, len(cfg.CONF.service_plugins)) self.assertEqual('fa:16:3e:00:00:00', cfg.CONF.base_mac) self.assertEqual(16, cfg.CONF.mac_generation_retries) diff --git a/neutron/tests/unit/test_db_plugin.py b/neutron/tests/unit/test_db_plugin.py index 651041c03e..c06d7563c0 100644 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@ -2211,8 +2211,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): self.assertEqual(1, len(res['networks'])) self.assertEqual(res['networks'][0]['name'], net1['network']['name']) - self.assertEqual(None, - res['networks'][0].get('id')) + self.assertIsNone(res['networks'][0].get('id')) def test_list_networks_with_parameters_invalid_values(self): with contextlib.nested(self.network(name='net1', @@ -3003,7 +3002,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = self.deserialize(self.fmt, req.get_response(self.api)) - self.assertEqual(None, data['subnet']['gateway_ip']) + self.assertIsNone(data['subnet']['gateway_ip']) def test_update_subnet(self): with self.subnet() as subnet: diff --git a/neutron/tests/unit/test_extension_ext_gw_mode.py b/neutron/tests/unit/test_extension_ext_gw_mode.py index 6d615ee0cd..585a4700f0 100644 --- a/neutron/tests/unit/test_extension_ext_gw_mode.py +++ b/neutron/tests/unit/test_extension_ext_gw_mode.py @@ -262,7 +262,7 @@ class TestL3GwModeMixin(base.BaseTestCase): def test_make_router_dict_no_ext_gw(self): self._reset_ext_gw() router_dict = self.target_object._make_router_dict(self.router) - self.assertEqual(None, router_dict[l3.EXTERNAL_GW_INFO]) + self.assertIsNone(router_dict[l3.EXTERNAL_GW_INFO]) def test_make_router_dict_with_ext_gw(self): router_dict = self.target_object._make_router_dict(self.router) diff --git a/neutron/tests/unit/test_extension_extraroute.py b/neutron/tests/unit/test_extension_extraroute.py index cbc07a843e..344ab1b39b 100644 --- a/neutron/tests/unit/test_extension_extraroute.py +++ b/neutron/tests/unit/test_extension_extraroute.py @@ -400,7 +400,7 @@ class ExtraRouteDBTestCaseBase(object): s['subnet']['network_id']) body = self._show('routers', r['router']['id']) gw_info = body['router']['external_gateway_info'] - self.assertEqual(gw_info, None) + self.assertIsNone(gw_info) def test_router_list_with_sort(self): with contextlib.nested(self.router(name='router1'), diff --git a/neutron/tests/unit/test_l3_plugin.py b/neutron/tests/unit/test_l3_plugin.py index 4f75b576cf..60281403e6 100644 --- a/neutron/tests/unit/test_l3_plugin.py +++ b/neutron/tests/unit/test_l3_plugin.py @@ -946,7 +946,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): s['subnet']['network_id']) body = self._show('routers', r['router']['id']) gw_info = body['router']['external_gateway_info'] - self.assertEqual(gw_info, None) + self.assertIsNone(gw_info) def test_router_add_gateway_tenant_ctx(self): with self.router(tenant_id='noadmin', @@ -966,7 +966,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): s['subnet']['network_id']) body = self._show('routers', r['router']['id']) gw_info = body['router']['external_gateway_info'] - self.assertEqual(gw_info, None) + self.assertIsNone(gw_info) def test_router_add_gateway_invalid_network_returns_404(self): with self.router() as r: @@ -1245,8 +1245,8 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): p['port']['fixed_ips'][0]['subnet_id']}} with self.floatingip_no_assoc(private_sub) as fip: body = self._show('floatingips', fip['floatingip']['id']) - self.assertEqual(body['floatingip']['port_id'], None) - self.assertEqual(body['floatingip']['fixed_ip_address'], None) + self.assertIsNone(body['floatingip']['port_id']) + self.assertIsNone(body['floatingip']['fixed_ip_address']) port_id = p['port']['id'] ip_address = p['port']['fixed_ips'][0]['ip_address'] @@ -1281,10 +1281,9 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): def assert_no_assoc(fip): body = self._show('floatingips', fip['floatingip']['id']) - self.assertEqual(body['floatingip']['port_id'], - None) + self.assertIsNone(body['floatingip']['port_id']) self.assertIsNone( - body['floatingip']['fixed_ip_address'], None) + body['floatingip']['fixed_ip_address']) assert_no_assoc(fip1) assert_no_assoc(fip2) @@ -1341,9 +1340,9 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): body = self._show('floatingips', fip['floatingip']['id']) self.assertEqual(body['floatingip']['id'], fip['floatingip']['id']) - self.assertEqual(body['floatingip']['port_id'], None) - self.assertEqual(body['floatingip']['fixed_ip_address'], None) - self.assertEqual(body['floatingip']['router_id'], None) + self.assertIsNone(body['floatingip']['port_id']) + self.assertIsNone(body['floatingip']['fixed_ip_address']) + self.assertIsNone(body['floatingip']['router_id']) def test_two_fips_one_port_invalid_return_409(self): with self.floatingip_with_assoc() as fip1: diff --git a/neutron/tests/unit/test_linux_ip_lib.py b/neutron/tests/unit/test_linux_ip_lib.py index 6c4eb5d0c6..b4d4f87382 100644 --- a/neutron/tests/unit/test_linux_ip_lib.py +++ b/neutron/tests/unit/test_linux_ip_lib.py @@ -345,7 +345,7 @@ class TestIPDevice(base.BaseTestCase): def test_eq_other_is_none(self): dev1 = ip_lib.IPDevice('tap0', 'sudo', 'ns1') - self.assertNotEqual(dev1, None) + self.assertIsNotNone(dev1) def test_str(self): self.assertEqual(str(ip_lib.IPDevice('tap0')), 'tap0') diff --git a/neutron/tests/unit/test_routerserviceinsertion.py b/neutron/tests/unit/test_routerserviceinsertion.py index da545a96c7..f9a4ab9bfc 100644 --- a/neutron/tests/unit/test_routerserviceinsertion.py +++ b/neutron/tests/unit/test_routerserviceinsertion.py @@ -269,7 +269,7 @@ class RouterServiceInsertionTestCase(base.BaseTestCase): def test_router_create_no_service_type_id(self): router = self._router_create() - self.assertEqual(router.get('service_type_id'), None) + self.assertIsNone(router.get('service_type_id')) def test_router_create_with_service_type_id(self): router = self._router_create(self._service_type_id)