From 75f7a2f29e3b23d69b4915cc2f3b22d789292ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Antal?= Date: Tue, 30 Aug 2016 19:09:20 +0200 Subject: [PATCH] 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 --- nova/test.py | 2 +- nova/tests/functional/db/test_aggregate.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/test.py b/nova/test.py index caf1f89b8..dad1a0011 100644 --- a/nova/test.py +++ b/nova/test.py @@ -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) diff --git a/nova/tests/functional/db/test_aggregate.py b/nova/tests/functional/db/test_aggregate.py index 74a713e55..10d300d45 100644 --- a/nova/tests/functional/db/test_aggregate.py +++ b/nova/tests/functional/db/test_aggregate.py @@ -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)