]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Correct handling mock.patch.stop method
authorHui HX Xiang <xianghui@cn.ibm.com>
Thu, 10 Oct 2013 06:10:31 +0000 (23:10 -0700)
committerHui HX Xiang <xianghui@cn.ibm.com>
Mon, 14 Oct 2013 15:02:34 +0000 (08:02 -0700)
Correct calling the right stop method of mock.patch object.

Change-Id: I53cffd78f7597a9a0dc8ec7dbc176d958c85be83

neutron/tests/unit/test_linux_dhcp.py

index 7842acb6f0f1b404fcd89eb85b09d0fb90a0349d..bd6b5dadcf6b3b1be65d6f34aedea6740cab159c 100644 (file)
@@ -307,7 +307,6 @@ class TestBase(base.BaseTestCase):
         self.conf.register_opts(dhcp.OPTS)
         instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager")
         self.mock_mgr = instance.start()
-        self.addCleanup(self.mock_mgr.stop)
         self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata',
                                            default=True))
         self.conf(args=args)
@@ -316,10 +315,9 @@ class TestBase(base.BaseTestCase):
 
         self.replace_p = mock.patch('neutron.agent.linux.utils.replace_file')
         self.execute_p = mock.patch('neutron.agent.linux.utils.execute')
-        self.addCleanup(self.replace_p.stop)
-        self.addCleanup(self.execute_p.stop)
         self.safe = self.replace_p.start()
         self.execute = self.execute_p.start()
+        self.addCleanup(mock.patch.stopall)
 
 
 class TestDhcpBase(TestBase):