From 56c48c65a55d6b6117c4636093871bcba5a34522 Mon Sep 17 00:00:00 2001 From: howardlee Date: Thu, 20 Oct 2016 11:10:18 +0800 Subject: [PATCH] [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 --- .../tests/drivers/pika/test_message.py | 8 ++++---- .../tests/drivers/zmq/test_zmq_ttl_cache.py | 18 +++++++++--------- .../tests/functional/notify/test_logger.py | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/oslo_messaging/tests/drivers/pika/test_message.py b/oslo_messaging/tests/drivers/pika/test_message.py index 354f3a399..630fb0df9 100644 --- a/oslo_messaging/tests/drivers/pika/test_message.py +++ b/oslo_messaging/tests/drivers/pika/test_message.py @@ -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)) diff --git a/oslo_messaging/tests/drivers/zmq/test_zmq_ttl_cache.py b/oslo_messaging/tests/drivers/zmq/test_zmq_ttl_cache.py index 60a5af0ac..dd041c94a 100644 --- a/oslo_messaging/tests/drivers/zmq/test_zmq_ttl_cache.py +++ b/oslo_messaging/tests/drivers/zmq/test_zmq_ttl_cache.py @@ -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() diff --git a/oslo_messaging/tests/functional/notify/test_logger.py b/oslo_messaging/tests/functional/notify/test_logger.py index 47167762e..56c0859f8 100644 --- a/oslo_messaging/tests/functional/notify/test_logger.py +++ b/oslo_messaging/tests/functional/notify/test_logger.py @@ -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()