Using assertIsNotNone() instead of assertNotEqual(None)

Following OpenStack Style Guidelines[1]:
[H203] Unit test assertions tend to give better messages for more
specific assertions. As a result, assertIsNotNone(...) is preferred
over assertNotEqual(None, ...) and assertIsNot(None, ...)

[1] http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises

Change-Id: Iadb27153109b2c4b92df43fc97a5e50eed86f58c
This commit is contained in:
Cao Xuan Hoang 2016-11-15 11:35:40 +07:00 committed by Steve Martinelli
parent 6858ccdd0f
commit b55a286462

View File

@ -64,11 +64,11 @@ actual =
matches = self.matches_matches
mismatches = self.matches_mismatches
for candidate in matches:
self.assertEqual(None, matcher.match(candidate))
self.assertIsNone(matcher.match(candidate))
for candidate in mismatches:
mismatch = matcher.match(candidate)
self.assertNotEqual(None, mismatch)
self.assertNotEqual(None, getattr(mismatch, 'describe', None))
self.assertIsNotNone(mismatch)
self.assertIsNotNone(getattr(mismatch, 'describe', None))
def test__str__(self):
# [(expected, object to __str__)].