Use suitable assert

Replace assertTrue(a in b) with assertIn(a, b)
Replace assertFalse(a in b) with assertNotIn(a, b)
Replace assertTrue(a is None) with assertIsNone(a)

Change-Id: I981c81908a823d9dbecbb2e139a86fbf589ce55e
This commit is contained in:
liuqing 2014-07-09 00:17:33 +08:00
parent 7f3be27367
commit 5c8a85e386
2 changed files with 4 additions and 4 deletions

View File

@ -345,7 +345,7 @@ class AlarmManagerTest(testtools.TestCase):
('DELETE', '/v2/alarms/victim-id', {}, None),
]
self.assertEqual(self.api.calls, expect)
self.assertTrue(deleted is None)
self.assertIsNone(deleted)
def test_get_from_alarm_class(self):
alarm = self.mgr.get(alarm_id='alarm-id')
@ -379,7 +379,7 @@ class AlarmManagerTest(testtools.TestCase):
('DELETE', '/v2/alarms/alarm-id', {}, None)
]
self.assertEqual(expect, self.api.calls)
self.assertTrue(deleted is None)
self.assertIsNone(deleted)
def _do_test_get_history(self, q, url):
history = self.mgr.get_history(q=q, alarm_id='alarm-id')

View File

@ -215,7 +215,7 @@ class ShellAlarmCommandTest(utils.BaseTestCase):
if repeat_actions is not None:
self.assertEqual(repeat_actions, kwargs.get('repeat_actions'))
else:
self.assertFalse('repeat_actions' in kwargs)
self.assertNotIn('repeat_actions', kwargs)
def test_alarm_update_repeat_actions_untouched(self):
method = ceilometer_shell.do_alarm_update
@ -281,7 +281,7 @@ class ShellAlarmCommandTest(utils.BaseTestCase):
self.assertEqual('instance running hot', kwargs.get('description'))
actions = ['log://', 'http://example.com/alarm/state']
self.assertEqual(actions, kwargs.get('alarm_actions'))
self.assertTrue('threshold_rule' in kwargs)
self.assertIn('threshold_rule', kwargs)
rule = kwargs['threshold_rule']
self.assertEqual('cpu_util', rule.get('meter_name'))
self.assertEqual(70.0, rule.get('threshold'))