Browse Source

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
changes/03/471703/1
Van Hung Pham 2 years ago
parent
commit
6b20f17624
3 changed files with 6 additions and 6 deletions
  1. 1
    1
      tests/unit/test_os_utils.py
  2. 1
    1
      tests/unit/test_plugin_kvm.py
  3. 4
    4
      tests/unit/test_utils.py

+ 1
- 1
tests/unit/test_os_utils.py View File

@@ -175,7 +175,7 @@ class TestOsUtils(unittest.TestCase):
175 175
         """Test retrieving consumer usage."""
176 176
         with mock.patch('openstack.connection.Connection') as MockClass:
177 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 180
     def test_get_consumer_usage_with_servers(self):
181 181
         """Test retrieving consumer usage with servers list."""

+ 1
- 1
tests/unit/test_plugin_kvm.py View File

@@ -107,7 +107,7 @@ class TestKvm(unittest.TestCase):
107 107
         """Ensure the run() method works."""
108 108
         sys.modules.pop('libvirt', None)
109 109
         result = tests.runner('kvm')
110
-        self.assertTrue(isinstance(result.exception, SystemExit))
110
+        self.assertIsInstance(result.exception, SystemExit)
111 111
 
112 112
     def test_run_failure(self):
113 113
         """Ensure the run() method works."""

+ 4
- 4
tests/unit/test_utils.py View File

@@ -49,13 +49,13 @@ class TestUtils(unittest.TestCase):
49 49
                 os.remove(cache_db)
50 50
 
51 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 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 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 60
     def test_read_config_not_found(self):  # noqa
61 61
         self.assertRaises(
@@ -65,7 +65,7 @@ class TestUtils(unittest.TestCase):
65 65
         )
66 66
 
67 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 70
     def test_read_config_found_defaults_in_sections(self):
71 71
         """Read config defaults from each section."""

Loading…
Cancel
Save