From 795e731f9ba2ddf604bf496a3e085de076a91f8b Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Fri, 6 Sep 2013 16:00:59 +0800 Subject: [PATCH] Utilize assertIsInstance Using assertTrue and the 'isinstance' function to test if an object is in an instance of some class is too python2.4. Our unit testing framework supports assertIsInstance which was created for these types of tests. Let's use assertIsInstance for these tests. Fixes bug #1230028 Change-Id: Ia03c9f19a1c5e2aef3a6fe530515bd26339a7975 --- neutron/tests/unit/nicira/test_nvp_api_request_eventlet.py | 2 +- neutron/tests/unit/test_linux_interface.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/neutron/tests/unit/nicira/test_nvp_api_request_eventlet.py b/neutron/tests/unit/nicira/test_nvp_api_request_eventlet.py index feb3bda192..1eb25a6e78 100644 --- a/neutron/tests/unit/nicira/test_nvp_api_request_eventlet.py +++ b/neutron/tests/unit/nicira/test_nvp_api_request_eventlet.py @@ -158,7 +158,7 @@ class NvpApiRequestEventletTest(base.BaseTestCase): self.req._issue_request() LOG.info('request_error: %s' % self.req._request_error) - self.assertTrue(isinstance(self.req._request_error, Exception)) + self.assertIsInstance(self.req._request_error, Exception) self.assertTrue(self.client.acquire_connection.called) def test_issue_request_handle_none_sock(self): diff --git a/neutron/tests/unit/test_linux_interface.py b/neutron/tests/unit/test_linux_interface.py index 2b5eb45168..d5576439e4 100644 --- a/neutron/tests/unit/test_linux_interface.py +++ b/neutron/tests/unit/test_linux_interface.py @@ -358,9 +358,7 @@ class TestMetaInterfaceDriver(TestBase): def test_get_driver_by_network_id(self): meta_interface = interface.MetaInterfaceDriver(self.conf) driver = meta_interface._get_driver_by_network_id('test') - self.assertTrue(isinstance( - driver, - interface.OVSInterfaceDriver)) + self.assertIsInstance(driver, interface.OVSInterfaceDriver) def test_set_device_plugin_tag(self): meta_interface = interface.MetaInterfaceDriver(self.conf)