diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-09-20 17:17:34 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-09-20 17:17:34 +0000 |
| commit | a76d9970dc7588d111428d521f396d6800510cb9 (patch) | |
| tree | a26b896e1ac0403415d6a09ebd06715167a9432f | |
| parent | ad4503d8340f0ef147d03ca789438067345e332e (diff) | |
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
| -rw-r--r-- | nova/tests/compute/test_resource_tracker.py | 9 |
1 files 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): # <insert exciting things that utilize resources> - 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']) |
