Browse Source

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
tags/1.1.0
Shuquan Huang 3 years ago
parent
commit
cfcef973e8

+ 4
- 4
ironic_python_agent/tests/unit/extensions/test_base.py View File

@@ -132,7 +132,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
132 132
         self.assertEqual({'param': 'v1'}, result.command_params)
133 133
         self.assertEqual(base.AgentCommandStatus.SUCCEEDED,
134 134
                          result.command_status)
135
-        self.assertEqual(None, result.command_error)
135
+        self.assertIsNone(result.command_error)
136 136
         self.assertEqual({'result': 'fake_async_command: v1'},
137 137
                          result.command_result)
138 138
         self.agent.force_heartbeat.assert_called_once_with()
@@ -146,7 +146,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
146 146
         self.assertEqual({'param': 'v1'}, result.command_params)
147 147
         self.assertEqual(base.AgentCommandStatus.SUCCEEDED,
148 148
                          result.command_status)
149
-        self.assertEqual(None, result.command_error)
149
+        self.assertIsNone(result.command_error)
150 150
         self.assertEqual({'result': 'fake_async_command: v1'},
151 151
                          result.command_result)
152 152
 
@@ -167,7 +167,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
167 167
         self.assertEqual(base.AgentCommandStatus.FAILED,
168 168
                          result.command_status)
169 169
         self.assertIsInstance(result.command_error, ExecutionError)
170
-        self.assertEqual(None, result.command_result)
170
+        self.assertIsNone(result.command_result)
171 171
         self.agent.force_heartbeat.assert_called_once_with()
172 172
 
173 173
     def test_async_command_name(self):
@@ -182,7 +182,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
182 182
         self.assertEqual({'param': 'v1'}, result.command_params)
183 183
         self.assertEqual(base.AgentCommandStatus.SUCCEEDED,
184 184
                          result.command_status)
185
-        self.assertEqual(None, result.command_error)
185
+        self.assertIsNone(result.command_error)
186 186
         self.assertEqual({'result': 'v1'}, result.command_result)
187 187
         # no need to force heartbeat on a sync command
188 188
         self.assertEqual(0, self.agent.force_heartbeat.call_count)

+ 1
- 1
ironic_python_agent/tests/unit/test_agent.py View File

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

+ 1
- 1
ironic_python_agent/tests/unit/test_encoding.py View File

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

Loading…
Cancel
Save