Using assertIsNone(x) instead of assertEqual(None, x)

TrivilalFix

Following OpenStack Style Guidelines:
[1] http://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(...) is preferred over
assertEqual(None, ...) and assertIs(..., None)

Change-Id: I0da4625e916380317959106d3f3dedc70d73f33e
This commit is contained in:
zhanghongtao 2017-03-23 10:53:31 +08:00
parent 6cf9b1cd68
commit b684b4dff1
2 changed files with 3 additions and 8 deletions

View File

@ -157,8 +157,7 @@ class LinuxSCSITestCase(base.TestCase):
def test_find_multipath_device_path_fail(self, exists_mock, sleep_mock):
fake_wwn = '1234567890'
found_path = self.linuxscsi.find_multipath_device_path(fake_wwn)
expected_path = None
self.assertEqual(expected_path, found_path)
self.assertIsNone(found_path)
@mock.patch.object(os.path, 'exists', return_value=False)
@mock.patch.object(time, 'sleep')

View File

@ -291,18 +291,14 @@ class BrickLvmTestCase(base.TestCase):
def test_thin_pool_provisioned_capacity(self):
self.vg.vg_thin_pool = "test-prov-cap-pool-unit"
self.vg.vg_name = 'test-prov-cap-vg-unit'
self.assertEqual(
None,
self.vg.create_thin_pool(name=self.vg.vg_thin_pool))
self.assertIsNone(self.vg.create_thin_pool(name=self.vg.vg_thin_pool))
self.assertEqual("9.50", self.vg.vg_thin_pool_size)
self.assertEqual(7.6, self.vg.vg_thin_pool_free_space)
self.assertEqual(3.0, self.vg.vg_provisioned_capacity)
self.vg.vg_thin_pool = "test-prov-cap-pool-no-unit"
self.vg.vg_name = 'test-prov-cap-vg-no-unit'
self.assertEqual(
None,
self.vg.create_thin_pool(name=self.vg.vg_thin_pool))
self.assertIsNone(self.vg.create_thin_pool(name=self.vg.vg_thin_pool))
self.assertEqual("9.50", self.vg.vg_thin_pool_size)
self.assertEqual(7.6, self.vg.vg_thin_pool_free_space)
self.assertEqual(3.0, self.vg.vg_provisioned_capacity)