From a76d9970dc7588d111428d521f396d6800510cb9 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Thu, 20 Sep 2012 17:17:34 +0000 Subject: Fix testContextClaimWithException It was using Exception as a test exception, which unfortunately hid a TypeError exception being generated by incorrect arguments to self.tracker.resource_claim(). This is a good example of why Exception shouldn't be used as a testing exception. Change-Id: I6c70f15ebe79c467f035725ca17b270c36273ab3 --- nova/tests/compute/test_resource_tracker.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nova/tests/compute/test_resource_tracker.py b/nova/tests/compute/test_resource_tracker.py index 0af0e4284..81b2be130 100644 --- a/nova/tests/compute/test_resource_tracker.py +++ b/nova/tests/compute/test_resource_tracker.py @@ -534,15 +534,14 @@ class ResourceTestCase(BaseTestCase): self.assertEqual(2, self.tracker.compute_node['local_gb_used']) def testContextClaimWithException(self): + instance = self._fake_instance(memory_mb=1, root_gb=1, ephemeral_gb=1) try: - with self.tracker.resource_claim(self.context, memory_mb=1, - disk_gb=1): + with self.tracker.resource_claim(self.context, instance): # - raise Exception("THE SKY IS FALLING") - except Exception: + raise test.TestingException() + except test.TestingException: pass - self.tracker.update_available_resource(self.context) self.assertEqual(0, self.tracker.compute_node['memory_mb_used']) self.assertEqual(0, self.tracker.compute_node['local_gb_used']) self.assertEqual(0, self.compute['memory_mb_used']) -- cgit