Use assertIn instead of assertTrue in tests
Since `assertIn` is provided for checking if value exists in given container, it is not formal to use `assertTrue` for it. Change-Id: Ie1392839b5ca436957463bb29f2784d48cfcbf75
This commit is contained in:
parent
9fac2a557e
commit
bf413a6539
@ -554,7 +554,7 @@ class ImageManagerTest(testtools.TestCase):
|
||||
except IOError as e:
|
||||
self.assertEqual(errno.EPIPE, e.errno)
|
||||
msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
|
||||
self.assertTrue(msg in str(e))
|
||||
self.assertIn(msg, str(e))
|
||||
|
||||
def test_data_req_id(self):
|
||||
params = {
|
||||
@ -897,7 +897,7 @@ class ImageTest(testtools.TestCase):
|
||||
except IOError as e:
|
||||
self.assertEqual(errno.EPIPE, e.errno)
|
||||
msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
|
||||
self.assertTrue(msg in str(e))
|
||||
self.assertIn(msg, str(e))
|
||||
|
||||
def test_data_with_checksum(self):
|
||||
image = self.mgr.get('3')
|
||||
@ -959,5 +959,5 @@ class UrlParameterTest(testtools.TestCase):
|
||||
shell.do_image_list(self.gc, FakeArg({"is_public": "True"}))
|
||||
parts = parse.urlparse(self.api.url)
|
||||
qs_dict = parse.parse_qs(parts.query)
|
||||
self.assertTrue('is_public' in qs_dict)
|
||||
self.assertIn('is_public', qs_dict)
|
||||
self.assertTrue(qs_dict['is_public'][0].lower() == "true")
|
||||
|
@ -466,7 +466,7 @@ class ShellStdinHandlingTests(testtools.TestCase):
|
||||
|
||||
self._do_update('44d2c7e1-de4e-4612-8aa2-ba26610c444f')
|
||||
|
||||
self.assertTrue('data' in self.collected_args[1])
|
||||
self.assertIn('data', self.collected_args[1])
|
||||
self.assertIsInstance(self.collected_args[1]['data'], file_type)
|
||||
self.assertEqual('Some Data',
|
||||
self.collected_args[1]['data'].read())
|
||||
@ -491,7 +491,7 @@ class ShellStdinHandlingTests(testtools.TestCase):
|
||||
|
||||
self._do_update('44d2c7e1-de4e-4612-8aa2-ba26610c444f')
|
||||
|
||||
self.assertTrue('data' in self.collected_args[1])
|
||||
self.assertIn('data', self.collected_args[1])
|
||||
self.assertIsInstance(self.collected_args[1]['data'], file_type)
|
||||
self.assertEqual('Some Data\n',
|
||||
self.collected_args[1]['data'].read())
|
||||
|
@ -826,7 +826,7 @@ class TestController(testtools.TestCase):
|
||||
except IOError as e:
|
||||
self.assertEqual(errno.EPIPE, e.errno)
|
||||
msg = 'was 9d3d9048db16a7eee539e93e3618cbe7 expected wrong'
|
||||
self.assertTrue(msg in str(e))
|
||||
self.assertIn(msg, str(e))
|
||||
|
||||
def test_data_with_checksum(self):
|
||||
body = self.controller.data('1b1c6366-dd57-11e1-af0f-02163e68b1d8',
|
||||
@ -989,17 +989,17 @@ class TestController(testtools.TestCase):
|
||||
e = self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.add_location,
|
||||
image_id, url, meta)
|
||||
self.assertTrue(estr in str(e))
|
||||
self.assertIn(estr, str(e))
|
||||
|
||||
e = self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.delete_locations,
|
||||
image_id, set([url]))
|
||||
self.assertTrue(estr in str(e))
|
||||
self.assertIn(estr, str(e))
|
||||
|
||||
e = self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.update_location,
|
||||
image_id, url, meta)
|
||||
self.assertTrue(estr in str(e))
|
||||
self.assertIn(estr, str(e))
|
||||
|
||||
def _empty_get(self, image_id):
|
||||
return ('GET', '/v2/images/%s' % image_id, {}, None)
|
||||
@ -1052,7 +1052,7 @@ class TestController(testtools.TestCase):
|
||||
err = self.assertRaises(exc.HTTPNotFound,
|
||||
self.controller.delete_locations,
|
||||
image_id, url_set)
|
||||
self.assertTrue(err_str in str(err))
|
||||
self.assertIn(err_str, str(err))
|
||||
|
||||
def test_update_location(self):
|
||||
image_id = 'a2b83adc-888e-11e3-8872-78acc0b951d8'
|
||||
@ -1095,4 +1095,4 @@ class TestController(testtools.TestCase):
|
||||
err = self.assertRaises(exc.HTTPNotFound,
|
||||
self.controller.update_location,
|
||||
image_id, **new_loc)
|
||||
self.assertTrue(err_str in str(err))
|
||||
self.assertIn(err_str, str(err))
|
||||
|
Loading…
Reference in New Issue
Block a user