[TrivialFix] Replace old style assertions with new style assertions

Replace 'assertEqual(None, ...)' with 'assertIsNone(...)'.
Replace 'assertTrue(a in b)' with ''assertIn(a, b).
Replace 'assertFalse(a in b)' with 'assertNotIn(a, b)'.

Change-Id: Ia13cb8465ec86c07867ef977f8ab0d0fdbabb1d4
This commit is contained in:
howardlee 2016-10-20 11:10:18 +08:00 committed by howard lee
parent 267ac50fd6
commit 56c48c65a5
3 changed files with 14 additions and 14 deletions

View File

@ -144,8 +144,8 @@ class RpcPikaIncomingMessageTestCase(unittest.TestCase):
self.assertEqual("context_value",
message.ctxt.get("key_context", None))
self.assertEqual(None, message.msg_id)
self.assertEqual(None, message.reply_q)
self.assertIsNone(message.msg_id)
self.assertIsNone(message.reply_q)
self.assertEqual("payload_value",
message.message.get("payload_key", None))
@ -160,8 +160,8 @@ class RpcPikaIncomingMessageTestCase(unittest.TestCase):
self.assertEqual("context_value",
message.ctxt.get("key_context", None))
self.assertEqual(None, message.msg_id)
self.assertEqual(None, message.reply_q)
self.assertIsNone(message.msg_id)
self.assertIsNone(message.reply_q)
self.assertEqual("payload_value",
message.message.get("payload_key", None))

View File

@ -47,7 +47,7 @@ class TestZmqTTLCache(test_utils.BaseTestCase):
time.sleep(1)
self.assertEqual(self.cache.get('x'), None)
self.assertIsNone(self.cache.get('x'))
self.assertEqual(self.cache.get('x', 'b'), 'b')
def test_add_get_with_executor(self):
@ -60,27 +60,27 @@ class TestZmqTTLCache(test_utils.BaseTestCase):
def _test_in_operator(self):
self.cache.add(1)
self.assertTrue(1 in self.cache)
self.assertIn(1, self.cache)
time.sleep(0.5)
self.cache.add(2)
self.assertTrue(1 in self.cache)
self.assertTrue(2 in self.cache)
self.assertIn(1, self.cache)
self.assertIn(2, self.cache)
time.sleep(0.75)
self.cache.add(3)
self.assertFalse(1 in self.cache)
self.assertTrue(2 in self.cache)
self.assertTrue(3 in self.cache)
self.assertNotIn(1, self.cache)
self.assertIn(2, self.cache)
self.assertIn(3, self.cache)
time.sleep(0.5)
self.assertFalse(2 in self.cache)
self.assertTrue(3 in self.cache)
self.assertNotIn(2, self.cache)
self.assertIn(3, self.cache)
def test_in_operator_with_executor(self):
self._test_in_operator()

View File

@ -78,7 +78,7 @@ class LoggingNotificationHandlerTestCase(utils.SkipIfNoTransportURL):
for key in ['name', 'thread', 'extra', 'process', 'funcName',
'levelno', 'processName', 'pathname', 'lineno',
'msg', 'exc_info', 'levelname']:
self.assertTrue(key in info_event[2])
self.assertIn(key, info_event[2])
LoggingNotificationHandlerTestCase.generate_scenarios()