Replace assertTrue(isinstance()) by optimal assert

assertTrue(isinstance(A, B)) or assertEqual(type(A), B) in tests
should be replaced by assertIsInstance(A, B) provided by testtools.
Closes-bug: #1268480

Change-Id: Ia43c944c56e66631c758cc5146150c2b5abb12ed
This commit is contained in:
LiuNanke 2016-01-10 03:27:07 +08:00
parent cc6e3bb960
commit 097efaba32
4 changed files with 7 additions and 7 deletions

View File

@ -27,7 +27,7 @@ class TestCategories(base.TestObjectCreation):
resp, body = self.client.list_categories()
self.assertEqual(200, resp.status)
self.assertTrue(isinstance(body['categories'], list))
self.assertIsInstance(body['categories'], list)
@tag('all', 'coverage')
@attr(type='smoke')

View File

@ -65,7 +65,7 @@ class TestRepositorySanity(TestCaseRepository):
resp, body = self.client.get_list_packages()
self.assertEqual(200, resp.status)
self.assertTrue(isinstance(body['packages'], list))
self.assertIsInstance(body['packages'], list)
@tag('all', 'coverage')
@attr(type='smoke')
@ -73,7 +73,7 @@ class TestRepositorySanity(TestCaseRepository):
resp, body = self.client.list_categories()
self.assertEqual(200, resp.status)
self.assertTrue(isinstance(body['categories'], list))
self.assertIsInstance(body['categories'], list)
@tag('all', 'coverage')
@attr(type='smoke')
@ -389,4 +389,4 @@ class TestRepository(TestCaseRepository):
resp, body = self.client.get_logo(self.package['id'])
self.assertEqual(200, resp.status)
self.assertTrue(isinstance(body, str))
self.assertIsInstance(body, str)

View File

@ -32,7 +32,7 @@ class TestServices(base.TestCase):
sess['id'])
self.assertEqual(resp.status, 200)
self.assertTrue(isinstance(services_list, list))
self.assertIsInstance(services_list, list)
@tag('all', 'coverage')
@attr(type='negative')

View File

@ -39,8 +39,8 @@ class PluginLoaderTest(base.MuranoTestCase):
test_obj.load_extension(ext, name_map)
self.assertEqual(1, len(test_obj.packages))
loaded_pkg = test_obj.packages.values()[0]
self.assertTrue(isinstance(loaded_pkg,
extensions_loader.PackageDefinition))
self.assertIsInstance(loaded_pkg,
extensions_loader.PackageDefinition)
self.assertEqual('test.namespace.Test', loaded_pkg.classes.keys()[0])
self.assertEqual({'test.namespace.Test': test_obj.packages.keys()},
name_map)