summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVan Hung Pham <hungpv@vn.fujitsu.com>2017-06-08 02:10:06 +0700
committerVan Hung Pham <hungpv@vn.fujitsu.com>2017-06-08 02:10:06 +0700
commit6b20f1762429c482257b9c372ee77cb54523d7c5 (patch)
tree676b847908ff925e7eab252ed97df428fe045ef6
parent6eae6ea8db74c9e0775460c37953a4f452e8f260 (diff)
Replace assertTrue(isinstance()) with assertIsInstance()
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: Ieb99417a4522f803e15547a9c7f6d781b6142678
Notes
Notes (review): Code-Review+2: Major Hayden <major@mhtx.net> Code-Review+2: Jesse Pretorius (odyssey4me) <jesse.pretorius@rackspace.co.uk> Workflow+1: Jesse Pretorius (odyssey4me) <jesse.pretorius@rackspace.co.uk> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 12 Jun 2017 13:32:00 +0000 Reviewed-on: https://review.openstack.org/471703 Project: openstack/monitorstack Branch: refs/heads/master
-rw-r--r--tests/unit/test_os_utils.py2
-rw-r--r--tests/unit/test_plugin_kvm.py2
-rw-r--r--tests/unit/test_utils.py8
3 files changed, 6 insertions, 6 deletions
diff --git a/tests/unit/test_os_utils.py b/tests/unit/test_os_utils.py
index 586cd20..4a5507a 100644
--- a/tests/unit/test_os_utils.py
+++ b/tests/unit/test_os_utils.py
@@ -175,7 +175,7 @@ class TestOsUtils(unittest.TestCase):
175 """Test retrieving consumer usage.""" 175 """Test retrieving consumer usage."""
176 with mock.patch('openstack.connection.Connection') as MockClass: 176 with mock.patch('openstack.connection.Connection') as MockClass:
177 MockClass.return_value = MockedOpenStackConn() 177 MockClass.return_value = MockedOpenStackConn()
178 self.assertTrue(isinstance(self.osu.get_consumer_usage(), list)) 178 self.assertIsInstance(self.osu.get_consumer_usage(), list)
179 179
180 def test_get_consumer_usage_with_servers(self): 180 def test_get_consumer_usage_with_servers(self):
181 """Test retrieving consumer usage with servers list.""" 181 """Test retrieving consumer usage with servers list."""
diff --git a/tests/unit/test_plugin_kvm.py b/tests/unit/test_plugin_kvm.py
index 277e1df..b4d8305 100644
--- a/tests/unit/test_plugin_kvm.py
+++ b/tests/unit/test_plugin_kvm.py
@@ -107,7 +107,7 @@ class TestKvm(unittest.TestCase):
107 """Ensure the run() method works.""" 107 """Ensure the run() method works."""
108 sys.modules.pop('libvirt', None) 108 sys.modules.pop('libvirt', None)
109 result = tests.runner('kvm') 109 result = tests.runner('kvm')
110 self.assertTrue(isinstance(result.exception, SystemExit)) 110 self.assertIsInstance(result.exception, SystemExit)
111 111
112 def test_run_failure(self): 112 def test_run_failure(self):
113 """Ensure the run() method works.""" 113 """Ensure the run() method works."""
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index c1a2648..73f5ff5 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -49,13 +49,13 @@ class TestUtils(unittest.TestCase):
49 os.remove(cache_db) 49 os.remove(cache_db)
50 50
51 def test_is_int_is_int(self): # noqa 51 def test_is_int_is_int(self): # noqa
52 self.assertTrue(isinstance(utils.is_int(value=1), int)) 52 self.assertIsInstance(utils.is_int(value=1), int)
53 53
54 def test_is_int_is_int_str(self): # noqa 54 def test_is_int_is_int_str(self): # noqa
55 self.assertTrue(isinstance(utils.is_int(value='1'), int)) 55 self.assertIsInstance(utils.is_int(value='1'), int)
56 56
57 def test_is_int_is_not_int(self): # noqa 57 def test_is_int_is_not_int(self): # noqa
58 self.assertTrue(isinstance(utils.is_int(value='a'), str)) 58 self.assertIsInstance(utils.is_int(value='a'), str)
59 59
60 def test_read_config_not_found(self): # noqa 60 def test_read_config_not_found(self): # noqa
61 self.assertRaises( 61 self.assertRaises(
@@ -65,7 +65,7 @@ class TestUtils(unittest.TestCase):
65 ) 65 )
66 66
67 def test_read_config_found_dict_return(self): # noqa 67 def test_read_config_found_dict_return(self): # noqa
68 self.assertTrue(isinstance(self.config, dict)) 68 self.assertIsInstance(self.config, dict)
69 69
70 def test_read_config_found_defaults_in_sections(self): 70 def test_read_config_found_defaults_in_sections(self):
71 """Read config defaults from each section.""" 71 """Read config defaults from each section."""