From 806f1cfe3f01a0cb5c717508683f50927c47af7a Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 9 Apr 2013 12:23:19 +1200 Subject: Fix a bad tearDown method in test_quantumv2.py. Cleanup code runs in LIFO order, so this was calling the mox methods in the wrong order. Secondly the whole point of addCleanup is to register code to run as soon as it is known that it should run, vs tearDown which only runs if setUp succeeds, and doesn't know what other code completed. Change-Id: Iff3b91e9d43cc58b667b32cacc4b97b6e0e1f298 --- nova/tests/network/test_quantumv2.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py index 6a3b31412..ab8752dec 100644 --- a/nova/tests/network/test_quantumv2.py +++ b/nova/tests/network/test_quantumv2.py @@ -129,6 +129,7 @@ class TestQuantumv2(test.TestCase): def setUp(self): super(TestQuantumv2, self).setUp() + self.addCleanup(CONF.reset) self.mox.StubOutWithMock(quantumv2, 'get_client') self.moxed_client = self.mox.CreateMock(client.Client) quantumv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn( @@ -238,13 +239,9 @@ class TestQuantumv2(test.TestCase): 'fixed_ip_address': fixed_ip_address, 'router_id': 'router_id1'} self._returned_nw_info = [] - - def tearDown(self): - self.addCleanup(CONF.reset) - self.addCleanup(self.mox.VerifyAll) - self.addCleanup(self.mox.UnsetStubs) self.addCleanup(self.stubs.UnsetAll) - super(TestQuantumv2, self).tearDown() + self.addCleanup(self.mox.UnsetStubs) + self.addCleanup(self.mox.VerifyAll) def _verify_nw_info(self, nw_inf, index=0): id_suffix = index + 1 -- cgit