diff options
author | Robert Collins <rbtcollins@hp.com> | 2013-01-22 11:53:38 +1300 |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2013-01-24 21:54:49 +1300 |
commit | 65f9d214d0ee98368fc979fa70fd7ff0996c86d9 (patch) | |
tree | 4506d98641b244e3070fa17457e4185e584a85ff | |
parent | a1c1e1bac155666d93f4003841132e66b3599ca8 (diff) | |
download | nova-65f9d214d0ee98368fc979fa70fd7ff0996c86d9.tar.gz nova-65f9d214d0ee98368fc979fa70fd7ff0996c86d9.tar.xz nova-65f9d214d0ee98368fc979fa70fd7ff0996c86d9.zip |
Make failures in the periodic tests more detailed.
The current tests are very opaque when something fails. This change makes the
failure easier to understand without a debugger. The testtools version is
bumped to get a new HasLength matcher.
Change-Id: Iceafa70f88a8cc31a1b0ba912fe32a9fef1b2f18
-rw-r--r-- | nova/tests/test_periodic_tasks.py | 18 | ||||
-rw-r--r-- | tools/test-requires | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/nova/tests/test_periodic_tasks.py b/nova/tests/test_periodic_tasks.py index 39669967f..3c63f6d4a 100644 --- a/nova/tests/test_periodic_tasks.py +++ b/nova/tests/test_periodic_tasks.py @@ -15,9 +15,10 @@ # License for the specific language governing permissions and limitations # under the License. +import time import fixtures -import time +from testtools import matchers from nova import manager from nova import test @@ -44,10 +45,11 @@ class ManagerMetaTestCase(test.TestCase): return 'baz' m = Manager() - self.assertEqual(2, len(m._periodic_tasks)) + self.assertThat(m._periodic_tasks, matchers.HasLength(2)) self.assertEqual(None, m._periodic_spacing['foo']) self.assertEqual(4, m._periodic_spacing['bar']) - self.assertFalse('baz' in m._periodic_spacing) + self.assertThat( + m._periodic_spacing, matchers.Not(matchers.Contains('baz'))) class Manager(test.TestCase): @@ -60,7 +62,7 @@ class Manager(test.TestCase): return 'bar' m = Manager() - self.assertEqual(1, len(m._periodic_tasks)) + self.assertThat(m._periodic_tasks, matchers.HasLength(1)) self.assertEqual(200, m._periodic_spacing['bar']) # Now a single pass of the periodic tasks @@ -87,8 +89,8 @@ class Manager(test.TestCase): m.periodic_tasks(None) time.sleep(0.1) idle = m.periodic_tasks(None) - self.assertTrue(idle > 9.7) - self.assertTrue(idle < 9.9) + self.assertThat(idle, matchers.GreaterThan(9.7)) + self.assertThat(idle, matchers.LessThan(9.9)) def test_periodic_tasks_disabled(self): class Manager(manager.Manager): @@ -109,7 +111,7 @@ class Manager(test.TestCase): return 'bar' m = Manager() - self.assertEqual(1, len(m._periodic_tasks)) + self.assertThat(m._periodic_tasks, matchers.HasLength(1)) def test_external_running_elsewhere(self): self.flags(run_external_periodic_tasks=False) @@ -120,4 +122,4 @@ class Manager(test.TestCase): return 'bar' m = Manager() - self.assertEqual(0, len(m._periodic_tasks)) + self.assertEqual([], m._periodic_tasks) diff --git a/tools/test-requires b/tools/test-requires index bc279166e..851023af4 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -12,4 +12,4 @@ pylint==0.25.2 python-subunit sphinx>=1.1.2 testrepository>=0.0.13 -testtools>=0.9.26 +testtools>=0.9.27 |