Browse Source

Replace assertEqual(None, *) with assertIsNone in tests

Replace assertEqual(None, *) with assertIsNone in tests to have
more clear messages in case of failure.

Change-Id: Ifbb144e26b62790d8b8ba9b5c3eea7d04844ee19
Closes-Bug:#1280522
tags/1.0.4
llg8212 5 years ago
parent
commit
ae837cf057

+ 19
- 19
troveclient/compat/tests/test_common.py View File

@@ -91,19 +91,19 @@ class CommonTest(testtools.TestCase):
91 91
 class CliOptionsTest(testtools.TestCase):
92 92
 
93 93
     def check_default_options(self, co):
94
-        self.assertEqual(None, co.username)
95
-        self.assertEqual(None, co.apikey)
96
-        self.assertEqual(None, co.tenant_id)
97
-        self.assertEqual(None, co.auth_url)
94
+        self.assertIsNone(co.username)
95
+        self.assertIsNone(co.apikey)
96
+        self.assertIsNone(co.tenant_id)
97
+        self.assertIsNone(co.auth_url)
98 98
         self.assertEqual('keystone', co.auth_type)
99 99
         self.assertEqual('database', co.service_type)
100 100
         self.assertEqual('RegionOne', co.region)
101
-        self.assertEqual(None, co.service_url)
101
+        self.assertIsNone(co.service_url)
102 102
         self.assertFalse(co.insecure)
103 103
         self.assertFalse(co.verbose)
104 104
         self.assertFalse(co.debug)
105
-        self.assertEqual(None, co.token)
106
-        self.assertEqual(None, co.xml)
105
+        self.assertIsNone(co.token)
106
+        self.assertIsNone(co.xml)
107 107
 
108 108
     def check_option(self, oparser, option_name):
109 109
         option = oparser.get_option("--%s" % option_name)
@@ -186,7 +186,7 @@ class CommandsBaseTest(testtools.TestCase):
186 186
 
187 187
         func = mock.Mock(side_effect=ValueError)  # an arbitrary exception
188 188
         r = self.cmd_base._safe_exec(func)
189
-        self.assertEqual(None, r)
189
+        self.assertIsNone(r)
190 190
 
191 191
     def test__prepare_parser(self):
192 192
         parser = optparse.OptionParser()
@@ -226,9 +226,9 @@ class CommandsBaseTest(testtools.TestCase):
226 226
     def test__pretty_print(self):
227 227
         func = mock.Mock(return_value=None)
228 228
         self.cmd_base.verbose = True
229
-        self.assertEqual(None, self.cmd_base._pretty_print(func))
229
+        self.assertIsNone(self.cmd_base._pretty_print(func))
230 230
         self.cmd_base.verbose = False
231
-        self.assertEqual(None, self.cmd_base._pretty_print(func))
231
+        self.assertIsNone(self.cmd_base._pretty_print(func))
232 232
 
233 233
     def test__dumps(self):
234 234
         json.dumps = mock.Mock(return_value="test-dump")
@@ -237,19 +237,19 @@ class CommandsBaseTest(testtools.TestCase):
237 237
     def test__pretty_list(self):
238 238
         func = mock.Mock(return_value=None)
239 239
         self.cmd_base.verbose = True
240
-        self.assertEqual(None, self.cmd_base._pretty_list(func))
240
+        self.assertIsNone(self.cmd_base._pretty_list(func))
241 241
         self.cmd_base.verbose = False
242
-        self.assertEqual(None, self.cmd_base._pretty_list(func))
242
+        self.assertIsNone(self.cmd_base._pretty_list(func))
243 243
         item = mock.Mock(return_value="test")
244 244
         item._info = "info"
245 245
         func = mock.Mock(return_value=[item])
246
-        self.assertEqual(None, self.cmd_base._pretty_list(func))
246
+        self.assertIsNone(self.cmd_base._pretty_list(func))
247 247
 
248 248
     def test__pretty_paged(self):
249 249
         self.cmd_base.limit = "5"
250 250
         func = mock.Mock(return_value=None)
251 251
         self.cmd_base.verbose = True
252
-        self.assertEqual(None, self.cmd_base._pretty_paged(func))
252
+        self.assertIsNone(self.cmd_base._pretty_paged(func))
253 253
 
254 254
         self.cmd_base.verbose = False
255 255
 
@@ -265,13 +265,13 @@ class CommandsBaseTest(testtools.TestCase):
265 265
 
266 266
         ret = MockIterable()
267 267
         func = mock.Mock(return_value=ret)
268
-        self.assertEqual(None, self.cmd_base._pretty_paged(func))
268
+        self.assertIsNone(self.cmd_base._pretty_paged(func))
269 269
 
270 270
         ret.count = 0
271
-        self.assertEqual(None, self.cmd_base._pretty_paged(func))
271
+        self.assertIsNone(self.cmd_base._pretty_paged(func))
272 272
 
273 273
         func = mock.Mock(side_effect=ValueError)
274
-        self.assertEqual(None, self.cmd_base._pretty_paged(func))
274
+        self.assertIsNone(self.cmd_base._pretty_paged(func))
275 275
         self.cmd_base.debug = True
276 276
         self.cmd_base.marker = mock.Mock()
277 277
         self.assertRaises(ValueError, self.cmd_base._pretty_paged, func)
@@ -294,8 +294,8 @@ class AuthTest(testtools.TestCase):
294 294
         sys.argv = self.orig_sys_argv
295 295
 
296 296
     def test___init__(self):
297
-        self.assertEqual(None, self.auth.dbaas)
298
-        self.assertEqual(None, self.auth.apikey)
297
+        self.assertIsNone(self.auth.dbaas)
298
+        self.assertIsNone(self.auth.apikey)
299 299
 
300 300
     def test_login(self):
301 301
         self.auth.username = "username"

+ 2
- 3
troveclient/compat/tests/test_xml.py View File

@@ -65,8 +65,7 @@ class XmlTest(object):
65 65
             '''
66 66
         rt = etree.fromstring(ele)
67 67
 
68
-        self.assertEqual(None,
69
-                         xml.populate_element_from_dict(rt, {'size': None}))
68
+        self.assertIsNone(xml.populate_element_from_dict(rt, {'size': None}))
70 69
 
71 70
     def test_element_must_be_list(self):
72 71
         # Test for when name isn't in the dictionary
@@ -137,7 +136,7 @@ class XmlTest(object):
137 136
                 </server>
138 137
             '''
139 138
         rt = etree.fromstring(element)
140
-        self.assertEqual(None, xml.element_to_dict(rt))
139
+        self.assertIsNone(xml.element_to_dict(rt))
141 140
 
142 141
     def test_standarize_json(self):
143 142
         xml.standardize_json_lists(self.JSON)

+ 2
- 2
troveclient/tests/test_base.py View File

@@ -414,7 +414,7 @@ class ResourceTest(testtools.TestCase):
414 414
         # Resource.HUMAN_ID is False
415 415
         robj = base.Resource(manager, info_)
416 416
         self.assertEqual(info_["id"], robj.id)
417
-        self.assertEqual(None, robj.human_id)
417
+        self.assertIsNone(robj.human_id)
418 418
         self.assertEqual(2, manager.write_to_completion_cache.call_count)
419 419
 
420 420
         # base.Resource.HUMAN_ID = True
@@ -430,7 +430,7 @@ class ResourceTest(testtools.TestCase):
430 430
 
431 431
         info_ = {"name": "test-human-id"}
432 432
         robj = base.Resource(manager, info_)
433
-        self.assertEqual(None, robj.human_id)
433
+        self.assertIsNone(robj.human_id)
434 434
 
435 435
         info_["HUMAN_ID"] = True
436 436
         robj = base.Resource(manager, info_)

+ 1
- 1
troveclient/tests/test_instances.py View File

@@ -140,7 +140,7 @@ class InstancesTest(testtools.TestCase):
140 140
         self.assertEqual('instance-1', self.instances._action(1, body))
141 141
 
142 142
         self.instances.api.client.post = mock.Mock(return_value=(resp, None))
143
-        self.assertEqual(None, self.instances._action(1, body))
143
+        self.assertIsNone(self.instances._action(1, body))
144 144
 
145 145
     def _set_action_mock(self):
146 146
         def side_effect_func(instance_id, body):

Loading…
Cancel
Save