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 /nova | |
| parent | a1c1e1bac155666d93f4003841132e66b3599ca8 (diff) | |
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
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/test_periodic_tasks.py | 18 |
1 files changed, 10 insertions, 8 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) |
