Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of assertTrue(isinstance(A, B)) or assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B) provided by testtools Change-Id: I0d2ec8ff3be41afb871ebd2aa71a8dfd13e2076d
This commit is contained in:
parent
56c48c65a5
commit
b28b2875c9
@ -1337,10 +1337,10 @@ class TestAddressing(test_utils.BaseTestCase):
|
||||
# simply check that the correct addresser is provided based on the
|
||||
# identity of the messaging back-end
|
||||
self.config(addressing_mode='dynamic', group="oslo_messaging_amqp")
|
||||
self.assertTrue(isinstance(self._dynamic_test("router"),
|
||||
RoutableAddresser))
|
||||
self.assertTrue(isinstance(self._dynamic_test("qpid-cpp"),
|
||||
LegacyAddresser))
|
||||
self.assertIsInstance(self._dynamic_test("router"),
|
||||
RoutableAddresser)
|
||||
self.assertIsInstance(self._dynamic_test("qpid-cpp"),
|
||||
LegacyAddresser)
|
||||
|
||||
|
||||
class FakeBroker(threading.Thread):
|
||||
|
@ -59,14 +59,14 @@ class TestGetPoller(test_utils.BaseTestCase):
|
||||
|
||||
poller = zmq_async.get_poller()
|
||||
|
||||
self.assertTrue(isinstance(poller, green_poller.GreenPoller))
|
||||
self.assertIsInstance(poller, green_poller.GreenPoller)
|
||||
|
||||
def test_when_eventlet_is_unavailable_then_return_ThreadingPoller(self):
|
||||
zmq_async.eventletutils.is_monkey_patched = lambda _: False
|
||||
|
||||
poller = zmq_async.get_poller()
|
||||
|
||||
self.assertTrue(isinstance(poller, threading_poller.ThreadingPoller))
|
||||
self.assertIsInstance(poller, threading_poller.ThreadingPoller)
|
||||
|
||||
|
||||
class TestGetExecutor(test_utils.BaseTestCase):
|
||||
@ -80,7 +80,7 @@ class TestGetExecutor(test_utils.BaseTestCase):
|
||||
|
||||
executor = zmq_async.get_executor('any method')
|
||||
|
||||
self.assertTrue(isinstance(executor, green_poller.GreenExecutor))
|
||||
self.assertIsInstance(executor, green_poller.GreenExecutor)
|
||||
self.assertEqual('any method', executor._method)
|
||||
|
||||
def test_when_eventlet_is_unavailable_then_return_ThreadingExecutor(self):
|
||||
@ -88,6 +88,6 @@ class TestGetExecutor(test_utils.BaseTestCase):
|
||||
|
||||
executor = zmq_async.get_executor('any method')
|
||||
|
||||
self.assertTrue(isinstance(executor,
|
||||
threading_poller.ThreadingExecutor))
|
||||
self.assertIsInstance(executor,
|
||||
threading_poller.ThreadingExecutor)
|
||||
self.assertEqual('any method', executor._method)
|
||||
|
@ -51,8 +51,8 @@ class TestConfigOptsProxy(test_utils.BaseTestCase):
|
||||
self.assertRaises(cfg.NoSuchOptError,
|
||||
conf.__getattr__,
|
||||
'unknown_group')
|
||||
self.assertTrue(isinstance(getattr(conf, group),
|
||||
conf.GroupAttrProxy))
|
||||
self.assertIsInstance(getattr(conf, group),
|
||||
conf.GroupAttrProxy)
|
||||
self.assertEqual(1, conf.oslo_messaging_rabbit.rabbit_retry_interval)
|
||||
self.assertEqual(2,
|
||||
conf.oslo_messaging_rabbit.rabbit_qos_prefetch_count)
|
||||
|
Loading…
Reference in New Issue
Block a user