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
|
# simply check that the correct addresser is provided based on the
|
||||||
# identity of the messaging back-end
|
# identity of the messaging back-end
|
||||||
self.config(addressing_mode='dynamic', group="oslo_messaging_amqp")
|
self.config(addressing_mode='dynamic', group="oslo_messaging_amqp")
|
||||||
self.assertTrue(isinstance(self._dynamic_test("router"),
|
self.assertIsInstance(self._dynamic_test("router"),
|
||||||
RoutableAddresser))
|
RoutableAddresser)
|
||||||
self.assertTrue(isinstance(self._dynamic_test("qpid-cpp"),
|
self.assertIsInstance(self._dynamic_test("qpid-cpp"),
|
||||||
LegacyAddresser))
|
LegacyAddresser)
|
||||||
|
|
||||||
|
|
||||||
class FakeBroker(threading.Thread):
|
class FakeBroker(threading.Thread):
|
||||||
|
@ -59,14 +59,14 @@ class TestGetPoller(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
poller = zmq_async.get_poller()
|
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):
|
def test_when_eventlet_is_unavailable_then_return_ThreadingPoller(self):
|
||||||
zmq_async.eventletutils.is_monkey_patched = lambda _: False
|
zmq_async.eventletutils.is_monkey_patched = lambda _: False
|
||||||
|
|
||||||
poller = zmq_async.get_poller()
|
poller = zmq_async.get_poller()
|
||||||
|
|
||||||
self.assertTrue(isinstance(poller, threading_poller.ThreadingPoller))
|
self.assertIsInstance(poller, threading_poller.ThreadingPoller)
|
||||||
|
|
||||||
|
|
||||||
class TestGetExecutor(test_utils.BaseTestCase):
|
class TestGetExecutor(test_utils.BaseTestCase):
|
||||||
@ -80,7 +80,7 @@ class TestGetExecutor(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
executor = zmq_async.get_executor('any method')
|
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)
|
self.assertEqual('any method', executor._method)
|
||||||
|
|
||||||
def test_when_eventlet_is_unavailable_then_return_ThreadingExecutor(self):
|
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')
|
executor = zmq_async.get_executor('any method')
|
||||||
|
|
||||||
self.assertTrue(isinstance(executor,
|
self.assertIsInstance(executor,
|
||||||
threading_poller.ThreadingExecutor))
|
threading_poller.ThreadingExecutor)
|
||||||
self.assertEqual('any method', executor._method)
|
self.assertEqual('any method', executor._method)
|
||||||
|
@ -51,8 +51,8 @@ class TestConfigOptsProxy(test_utils.BaseTestCase):
|
|||||||
self.assertRaises(cfg.NoSuchOptError,
|
self.assertRaises(cfg.NoSuchOptError,
|
||||||
conf.__getattr__,
|
conf.__getattr__,
|
||||||
'unknown_group')
|
'unknown_group')
|
||||||
self.assertTrue(isinstance(getattr(conf, group),
|
self.assertIsInstance(getattr(conf, group),
|
||||||
conf.GroupAttrProxy))
|
conf.GroupAttrProxy)
|
||||||
self.assertEqual(1, conf.oslo_messaging_rabbit.rabbit_retry_interval)
|
self.assertEqual(1, conf.oslo_messaging_rabbit.rabbit_retry_interval)
|
||||||
self.assertEqual(2,
|
self.assertEqual(2,
|
||||||
conf.oslo_messaging_rabbit.rabbit_qos_prefetch_count)
|
conf.oslo_messaging_rabbit.rabbit_qos_prefetch_count)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user