]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Don't restore stopped mock that is initialized in setUp()
authorIhar Hrachyshka <ihrachys@redhat.com>
Thu, 4 Dec 2014 10:31:24 +0000 (11:31 +0100)
committerIhar Hrachyshka <ihrachys@redhat.com>
Fri, 12 Dec 2014 15:35:49 +0000 (16:35 +0100)
Since this mock will be reinitialized for consequent test cases when
calling setUp(), it's not needed to restart it in the case.

Change-Id: Ib120bf09d24dccc0b09fae906dae05c69efe734a

neutron/tests/unit/test_l3_agent.py

index e50eda7cc00aef1119f083500bb39b989fe9edeb..41bd46d61873f0664992ea822b4a1e224320a030 100644 (file)
@@ -2217,22 +2217,19 @@ class TestL3AgentEventHandler(base.BaseTestCase):
 
         self.external_process_p.stop()
         ri = l3router.RouterInfo(router_id, None, None)
-        try:
-            with mock.patch(ip_class_path) as ip_mock:
-                self.agent._spawn_metadata_proxy(ri.router_id, ri.ns_name)
-                ip_mock.assert_has_calls([
-                    mock.call('sudo', ri.ns_name),
-                    mock.call().netns.execute([
-                        'neutron-ns-metadata-proxy',
-                        mock.ANY,
-                        mock.ANY,
-                        '--router_id=%s' % router_id,
-                        mock.ANY,
-                        '--metadata_port=%s' % metadata_port,
-                        '--debug',
-                        '--log-file=neutron-ns-metadata-proxy-%s.log' %
-                        router_id
-                    ], addl_env=None)
-                ])
-        finally:
-            self.external_process_p.start()
+        with mock.patch(ip_class_path) as ip_mock:
+            self.agent._spawn_metadata_proxy(ri.router_id, ri.ns_name)
+            ip_mock.assert_has_calls([
+                mock.call('sudo', ri.ns_name),
+                mock.call().netns.execute([
+                    'neutron-ns-metadata-proxy',
+                    mock.ANY,
+                    mock.ANY,
+                    '--router_id=%s' % router_id,
+                    mock.ANY,
+                    '--metadata_port=%s' % metadata_port,
+                    '--debug',
+                    '--log-file=neutron-ns-metadata-proxy-%s.log' %
+                    router_id
+                ], addl_env=None)
+            ])