Change assertTrue(isinstance()) by optimal assert

Some of tests use different method of assertTrue(isinstance(A, B)) or
assertEqual(type(A), B). The correct way is to use assertIsInstance(A,
B) provided by testtools.

Change-Id: I8e95e10fac4748b115838b6b480f1085da73f28a
Closes-bug: #1268480
This commit is contained in:
Shuquan Huang 2015-12-30 22:38:25 +08:00
parent 55239c2199
commit fac700c8e7
2 changed files with 5 additions and 5 deletions

View File

@ -67,8 +67,8 @@ class TestFlowExtension(test_base.BaseTestCase):
result = self.agent_extension.start_flow(flow=FLOW_INFO)
result.join()
self.assertEqual(base.AgentCommandStatus.FAILED, result.command_status)
self.assertTrue(isinstance(result.command_error,
errors.CommandExecutionError))
self.assertIsInstance(result.command_error,
errors.CommandExecutionError)
@mock.patch('time.sleep', autospec=True)
def test_sleep_flow_failed_on_second_command(self, sleep_mock):
@ -76,8 +76,8 @@ class TestFlowExtension(test_base.BaseTestCase):
result = self.agent_extension.start_flow(flow=FLOW_INFO[:4])
result.join()
self.assertEqual(base.AgentCommandStatus.FAILED, result.command_status)
self.assertTrue(isinstance(result.command_error,
errors.CommandExecutionError))
self.assertIsInstance(result.command_error,
errors.CommandExecutionError)
self.assertEqual(2, sleep_mock.call_count)
def test_validate_exts_success(self):

View File

@ -159,7 +159,7 @@ class TestBaseAgent(test_base.BaseTestCase):
self.agent.started_at = started_at
status = self.agent.get_status()
self.assertTrue(isinstance(status, agent.IronicPythonAgentStatus))
self.assertIsInstance(status, agent.IronicPythonAgentStatus)
self.assertEqual(started_at, status.started_at)
self.assertEqual(pkg_resources.get_distribution('ironic-python-agent')
.version, status.version)