Replace assertEqual(None, *) with assertIsNone in tests

Replace assertEqual(None, *) with assertIsNone in tests to have
more clear messages in case of failure.

Change-Id: Iad3f8fbb23a8b0f9e5ae4f304799465724c1a433
Closes-bug: #1280522
This commit is contained in:
Shuquan Huang 2015-12-17 11:31:29 +08:00
parent 15e4454e68
commit cfcef973e8
3 changed files with 6 additions and 6 deletions

View File

@ -132,7 +132,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
self.assertEqual({'param': 'v1'}, result.command_params)
self.assertEqual(base.AgentCommandStatus.SUCCEEDED,
result.command_status)
self.assertEqual(None, result.command_error)
self.assertIsNone(result.command_error)
self.assertEqual({'result': 'fake_async_command: v1'},
result.command_result)
self.agent.force_heartbeat.assert_called_once_with()
@ -146,7 +146,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
self.assertEqual({'param': 'v1'}, result.command_params)
self.assertEqual(base.AgentCommandStatus.SUCCEEDED,
result.command_status)
self.assertEqual(None, result.command_error)
self.assertIsNone(result.command_error)
self.assertEqual({'result': 'fake_async_command: v1'},
result.command_result)
@ -167,7 +167,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
self.assertEqual(base.AgentCommandStatus.FAILED,
result.command_status)
self.assertIsInstance(result.command_error, ExecutionError)
self.assertEqual(None, result.command_result)
self.assertIsNone(result.command_result)
self.agent.force_heartbeat.assert_called_once_with()
def test_async_command_name(self):
@ -182,7 +182,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
self.assertEqual({'param': 'v1'}, result.command_params)
self.assertEqual(base.AgentCommandStatus.SUCCEEDED,
result.command_status)
self.assertEqual(None, result.command_error)
self.assertIsNone(result.command_error)
self.assertEqual({'result': 'v1'}, result.command_result)
# no need to force heartbeat on a sync command
self.assertEqual(0, self.agent.force_heartbeat.call_count)

View File

@ -271,7 +271,7 @@ class TestBaseAgent(test_base.BaseTestCase):
self.assertRaises(errors.LookupAgentIPError,
homeless_agent.set_agent_advertise_addr)
self.assertEqual(6, mock_get_ipv4.call_count)
self.assertEqual(None, homeless_agent.network_interface)
self.assertIsNone(homeless_agent.network_interface)
# First interface eth0 has no IP, second interface eth1 has an IP
mock_get_ipv4.side_effect = [None, '1.1.1.1']

View File

@ -59,4 +59,4 @@ class TestSerializableComparable(test_base.BaseTestCase):
def test_childclass_hash(self):
# Ensure __hash__ is None
obj = SerializableComparableTesting('hello', 'world')
self.assertEqual(None, obj.__hash__)
self.assertIsNone(obj.__hash__)