From ecee40d4acb699f301b76b7e90f300728682bfba Mon Sep 17 00:00:00 2001 From: Vu Cong Tuan Date: Sat, 3 Jun 2017 16:11:12 +0700 Subject: [PATCH] Using assertIsNone(xxx) instead of assertEqual(None, xxx) Refer to OpenStack Style Guidelines: https://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises [H203] Unit test assertions tend to give better messages for more specific assertions. As a result, assertIsNone(xxx) is preferred over assertEqual(None, xxx) Change-Id: I47d8974511cd3ebe927f0ee19ee6b0713dc6508d --- tripleo_common/tests/actions/test_baremetal.py | 10 +++++----- tripleo_common/tests/actions/test_package_update.py | 2 +- tripleo_common/tests/actions/test_validations.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tripleo_common/tests/actions/test_baremetal.py b/tripleo_common/tests/actions/test_baremetal.py index 210e84f66..1715b3d05 100644 --- a/tripleo_common/tests/actions/test_baremetal.py +++ b/tripleo_common/tests/actions/test_baremetal.py @@ -63,7 +63,7 @@ class TestConfigureBootAction(base.TestCase): action = baremetal.ConfigureBootAction(node_uuid='MOCK_UUID', instance_boot_option='netboot') result = action.run(self.context) - self.assertEqual(result, None) + self.assertIsNone(result) self.node_update[0].update({'value': 'boot_option:netboot'}) self.ironic.node.update.assert_called_once_with(mock.ANY, @@ -72,7 +72,7 @@ class TestConfigureBootAction(base.TestCase): def test_run_instance_boot_option_not_set(self): action = baremetal.ConfigureBootAction(node_uuid='MOCK_UUID') result = action.run(self.context) - self.assertEqual(result, None) + self.assertIsNone(result) self.node_update[0].update({'value': 'boot_option:local'}) self.ironic.node.update.assert_called_once_with(mock.ANY, @@ -85,7 +85,7 @@ class TestConfigureBootAction(base.TestCase): action = baremetal.ConfigureBootAction(node_uuid='MOCK_UUID') result = action.run(self.context) - self.assertEqual(result, None) + self.assertIsNone(result) self.node_update[0].update({'value': 'boot_option:netboot'}) self.ironic.node.update.assert_called_once_with(mock.ANY, @@ -99,7 +99,7 @@ class TestConfigureBootAction(base.TestCase): action = baremetal.ConfigureBootAction(node_uuid='MOCK_UUID', instance_boot_option='local') result = action.run(self.context) - self.assertEqual(result, None) + self.assertIsNone(result) self.node_update[0].update({'value': 'boot_option:local'}) self.ironic.node.update.assert_called_once_with(mock.ANY, @@ -116,7 +116,7 @@ class TestConfigureBootAction(base.TestCase): ramdisk_name='test_ramdisk') result = action.run(self.context) - self.assertEqual(result, None) + self.assertIsNone(result) self.node_update[1].update({'value': 'test_ramdisk_id'}) self.node_update[2].update({'value': 'test_kernel_id'}) diff --git a/tripleo_common/tests/actions/test_package_update.py b/tripleo_common/tests/actions/test_package_update.py index c0584622c..53596def8 100644 --- a/tripleo_common/tests/actions/test_package_update.py +++ b/tripleo_common/tests/actions/test_package_update.py @@ -37,7 +37,7 @@ class ClearBreakpointsActionTest(base.TestCase): action = package_update.ClearBreakpointsAction(self.stack_id, self.refs) result = action.run(mock_ctx) - self.assertEqual(None, result) + self.assertIsNone(result) mock_compute_client.assert_called_once() mock_orchestration_client.assert_called_once() mock_update_manager.assert_called_once_with( diff --git a/tripleo_common/tests/actions/test_validations.py b/tripleo_common/tests/actions/test_validations.py index 1c8b8c96c..b28f81117 100644 --- a/tripleo_common/tests/actions/test_validations.py +++ b/tripleo_common/tests/actions/test_validations.py @@ -615,7 +615,7 @@ class TestVerifyProfilesAction(base.TestCase): self.assertEqual(expected.error['errors'].sort(), result.error['errors'].sort()) self.assertEqual(expected.error['warnings'], result.error['warnings']) - self.assertEqual(None, result.data) + self.assertIsNone(result.data) def test_not_enough_nodes(self): self.nodes[:] = [self._get_fake_node(profile='compute')] @@ -677,7 +677,7 @@ class TestVerifyProfilesAction(base.TestCase): self.assertEqual(expected.error['errors'].sort(), result.error['errors'].sort()) self.assertEqual(expected.error['warnings'], result.error['warnings']) - self.assertEqual(None, result.data) + self.assertIsNone(result.data) def test_no_spurious_warnings(self): self.nodes[:] = [self._get_fake_node(profile=None)]