Use more specific asserts in tests

Use asserts with more specific assert methods, e.g.: from
assertTrue(sth == None) to assertIsNone(*),
assertTrue(isinstance(inst, type)) to assertIsInstace(inst, type) or
assertTrue(not sth) to assertFalse(sth).

This change ensures a better description will be shown on fail. This is
the recommended way to use assertions provided by testtools.

Change-Id: Ia4a34e0145176e077bbf7e9ed6f69d815c6ed840
Co-authored-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Gábor Antal 2016-08-30 19:09:20 +02:00 committed by Stephen Finucane
parent 265bfba54a
commit 75f7a2f29e
2 changed files with 3 additions and 3 deletions

View File

@ -392,7 +392,7 @@ class APICoverage(object):
cover_api = None
def test_api_methods(self):
self.assertTrue(self.cover_api is not None)
self.assertIsNotNone(self.cover_api)
api_methods = [x for x in dir(self.cover_api)
if not x.startswith('_')]
test_methods = [x[5:] for x in dir(self)

View File

@ -132,8 +132,8 @@ class AggregateObjectDbTestCase(test.NoDBTestCase):
cell_db_agg = aggregate_obj.Aggregate.get_by_id(
self.context, ca2['id'])
self.assertEqual(api_db_agg.in_api, True)
self.assertEqual(cell_db_agg.in_api, False)
self.assertTrue(api_db_agg.in_api)
self.assertFalse(cell_db_agg.in_api)
def test_aggregate_get_from_db(self):
result = _create_aggregate_with_hosts(self.context)