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: Ie2631ce6d5f1756fe520850be0e0d304f41ba760
This commit is contained in:
parent
c22d37b51c
commit
71b0ff69fa
|
@ -106,7 +106,7 @@ class CliOptionsTest(testtools.TestCase):
|
||||||
|
|
||||||
def check_option(self, oparser, option_name):
|
def check_option(self, oparser, option_name):
|
||||||
option = oparser.get_option("--%s" % option_name)
|
option = oparser.get_option("--%s" % option_name)
|
||||||
self.assertNotEqual(None, option)
|
self.assertIsNotNone(option)
|
||||||
if option_name in common.CliOptions.DEFAULT_VALUES:
|
if option_name in common.CliOptions.DEFAULT_VALUES:
|
||||||
self.assertEqual(common.CliOptions.DEFAULT_VALUES[option_name],
|
self.assertEqual(common.CliOptions.DEFAULT_VALUES[option_name],
|
||||||
option.default)
|
option.default)
|
||||||
|
@ -171,7 +171,7 @@ class CommandsBaseTest(testtools.TestCase):
|
||||||
sys.argv = self.orig_sys_argv
|
sys.argv = self.orig_sys_argv
|
||||||
|
|
||||||
def test___init__(self):
|
def test___init__(self):
|
||||||
self.assertNotEqual(None, self.cmd_base)
|
self.assertIsNotNone(self.cmd_base)
|
||||||
|
|
||||||
def test__safe_exec(self):
|
def test__safe_exec(self):
|
||||||
func = mock.Mock(return_value="test")
|
func = mock.Mock(return_value="test")
|
||||||
|
@ -192,9 +192,9 @@ class CommandsBaseTest(testtools.TestCase):
|
||||||
common.CommandsBase.params = ["test_1", "test_2"]
|
common.CommandsBase.params = ["test_1", "test_2"]
|
||||||
self.cmd_base._prepare_parser(parser)
|
self.cmd_base._prepare_parser(parser)
|
||||||
option = parser.get_option("--%s" % "test_1")
|
option = parser.get_option("--%s" % "test_1")
|
||||||
self.assertNotEqual(None, option)
|
self.assertIsNotNone(option)
|
||||||
option = parser.get_option("--%s" % "test_2")
|
option = parser.get_option("--%s" % "test_2")
|
||||||
self.assertNotEqual(None, option)
|
self.assertIsNotNone(option)
|
||||||
|
|
||||||
def test__parse_options(self):
|
def test__parse_options(self):
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
|
|
Loading…
Reference in New Issue