Using assertIs(Not)None() instead of assert(Not)Equal(None)
Following OpenStack Style Guidelines[1]: [H203] Unit test assertions tend to give better messages for more specific assertions. As a result, assertIsNotNone(...) is preferred over assertNotEqual(None, ...) and assertIsNot(None, ...) [1] http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises Change-Id: I87f2df27b37506bb31ac410c867d5c3d7c739c3f
This commit is contained in:
parent
862b6713dc
commit
34fbb92921
@ -148,7 +148,7 @@ class RouterSizeBaseTest(base.BaseRouterTest):
|
||||
wait_till = time.time() + del_waitfor
|
||||
while (time.time() < wait_till):
|
||||
try:
|
||||
self.assertEqual(self.vsm.get_edge(nsxv_edge_name), None)
|
||||
self.assertIsNone(self.vsm.get_edge(nsxv_edge_name))
|
||||
return
|
||||
except Exception:
|
||||
time.sleep(del_interval)
|
||||
|
@ -137,4 +137,4 @@ class ExcRouterTest(base.BaseRouterTest):
|
||||
routers_list = [r['id'] for r in list_body['routers']]
|
||||
self.assertNotIn(router['router']['id'], routers_list)
|
||||
nsxv_edge_name = "%s-%s" % (name, router['router']['id'])
|
||||
self.assertEqual(self.vsm.get_edge(nsxv_edge_name), None)
|
||||
self.assertIsNone(self.vsm.get_edge(nsxv_edge_name))
|
||||
|
@ -108,10 +108,10 @@ class NSXv3NativeDHCPTest(base.BaseNetworkTest):
|
||||
self.assertEqual('ACTIVE', network['status'])
|
||||
nsx_network = self.nsx.get_logical_switch(network['name'],
|
||||
network['id'])
|
||||
self.assertNotEqual(nsx_network, None)
|
||||
self.assertIsNotNone(nsx_network)
|
||||
dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
self.assertNotEqual(dhcp_server, None)
|
||||
self.assertIsNotNone(dhcp_server)
|
||||
|
||||
@test.attr(type='nsxv3')
|
||||
@test.idempotent_id('cc970d9b-786a-49c3-8bfb-2f8bc5580ead')
|
||||
@ -132,7 +132,7 @@ class NSXv3NativeDHCPTest(base.BaseNetworkTest):
|
||||
nsx_dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
dhcp_server = nsx_dhcp_server['ipv4_dhcp_server']
|
||||
self.assertNotEqual(dhcp_server, None)
|
||||
self.assertIsNotNone(dhcp_server)
|
||||
self.assertEqual(dhcp_server['dhcp_server_ip'], "192.168.100.2/24")
|
||||
self.assertEqual(dhcp_server['gateway_ip'],
|
||||
self._subnet_data['gateway'])
|
||||
|
@ -61,8 +61,8 @@ class NSXv3NativeDHCPNegative(base.BaseNetworkTest):
|
||||
network['id'])
|
||||
dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
self.assertNotEqual(nsx_switch, None)
|
||||
self.assertEqual(dhcp_server, None)
|
||||
self.assertIsNotNone(nsx_switch)
|
||||
self.assertIsNone(dhcp_server)
|
||||
|
||||
@test.attr(type='nsxv3')
|
||||
@test.attr(type=['negative'])
|
||||
@ -79,8 +79,8 @@ class NSXv3NativeDHCPNegative(base.BaseNetworkTest):
|
||||
network['id'])
|
||||
dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
self.assertNotEqual(nsx_switch, None)
|
||||
self.assertEqual(dhcp_server, None)
|
||||
self.assertIsNotNone(nsx_switch)
|
||||
self.assertIsNone(dhcp_server)
|
||||
|
||||
@test.attr(type='nsxv3')
|
||||
@test.attr(type=['negative'])
|
||||
@ -97,10 +97,10 @@ class NSXv3NativeDHCPNegative(base.BaseNetworkTest):
|
||||
network['id'])
|
||||
dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
self.assertNotEqual(nsx_switch, None)
|
||||
self.assertNotEqual(dhcp_server, None)
|
||||
self.assertIsNotNone(nsx_switch)
|
||||
self.assertIsNotNone(dhcp_server)
|
||||
# Update subnet to disable DHCP
|
||||
self.subnets_client.update_subnet(subnet['id'], enable_dhcp=False)
|
||||
dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
self.assertEqual(dhcp_server, None)
|
||||
self.assertIsNone(dhcp_server)
|
||||
|
@ -46,7 +46,7 @@ class NSXv3NetworksTest(base.BaseNetworkTest):
|
||||
nsx_network = self.nsx.get_logical_switch(network['name'],
|
||||
network['id'])
|
||||
self.assertEqual('ACTIVE', network['status'])
|
||||
self.assertNotEqual(nsx_network, None)
|
||||
self.assertIsNotNone(nsx_network)
|
||||
# Verify network update
|
||||
new_name = "New_network"
|
||||
body = self.networks_client.update_network(net_id, name=new_name)
|
||||
@ -54,9 +54,9 @@ class NSXv3NetworksTest(base.BaseNetworkTest):
|
||||
nsx_network = self.nsx.get_logical_switch(updated_net['name'],
|
||||
updated_net['id'])
|
||||
self.assertEqual(updated_net['name'], new_name)
|
||||
self.assertNotEqual(nsx_network, None)
|
||||
self.assertIsNotNone(nsx_network)
|
||||
# Verify delete network
|
||||
self.networks_client.delete_network(updated_net['id'])
|
||||
nsx_network = self.nsx.get_logical_switch(updated_net['name'],
|
||||
updated_net['id'])
|
||||
self.assertEqual(nsx_network, None)
|
||||
self.assertIsNone(nsx_network)
|
||||
|
@ -109,7 +109,7 @@ class NSXv3DHCPUniScaleTest(base.BaseNetworkTest):
|
||||
self.create_subnet(network)
|
||||
dhcp_server = self.nsx.get_logical_dhcp_server(network['name'],
|
||||
network['id'])
|
||||
self.assertNotEqual(dhcp_server, None)
|
||||
self.assertIsNotNone(dhcp_server)
|
||||
for i in range(scale):
|
||||
port = self.create_port(network, device_owner='compute:None')
|
||||
self.addCleanup(self.ports_client.delete_port, port['id'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user