From 3dcbdafdf97f3d8034703f91c640e8510f28071f Mon Sep 17 00:00:00 2001 From: howardlee Date: Wed, 16 Nov 2016 14:51:24 +0800 Subject: [PATCH] Use assertIs(Not)None to check for None [H203] Use assertIs(Not)None to check for None (off by default) Unit test assertions tend to give better messages for more specific assertions. As a result, assertIsNone(...) is preferred over assertEqual(None, ...) and assertIs(None, ...), and assertIsNotNone(...) is preferred over assertNotEqual(None, ...) and assertIsNot(None, ...). Off by default. More information, see: http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises Change-Id: I73a9ed3e145b8f36c110725d148baf1fb0aef957 --- tempest/tests/common/test_custom_matchers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tempest/tests/common/test_custom_matchers.py b/tempest/tests/common/test_custom_matchers.py index 07867fc244..1053d861a5 100644 --- a/tempest/tests/common/test_custom_matchers.py +++ b/tempest/tests/common/test_custom_matchers.py @@ -25,11 +25,11 @@ class TestMatchersInterface(object): 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__)].