From: Miguel Angel Ajo Date: Fri, 28 Aug 2015 05:49:28 +0000 (+0200) Subject: Stops patching an object method which could be gone at cleanup X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ce3fb9065efacdc9e8503f5ba630c4ba1b85855f;p=openstack-build%2Fneutron-build.git Stops patching an object method which could be gone at cleanup Stop patching the qos plugin 'notification_driver_manager' method and instead substitute for a mock since it's destroyed and reloaded on every test run. Closes-Bug: #1489716 Change-Id: I0e84b19bba92a7cbef837de7994a605a78936250 --- diff --git a/neutron/tests/unit/services/qos/test_qos_plugin.py b/neutron/tests/unit/services/qos/test_qos_plugin.py index 246f5fab1..6dea3bdfa 100644 --- a/neutron/tests/unit/services/qos/test_qos_plugin.py +++ b/neutron/tests/unit/services/qos/test_qos_plugin.py @@ -46,8 +46,7 @@ class TestQosPlugin(base.BaseQosTestCase): self.qos_plugin = mgr.get_service_plugins().get( constants.QOS) - self.notif_driver_m = mock.patch.object( - self.qos_plugin, 'notification_driver_manager').start() + self.qos_plugin.notification_driver_manager = mock.Mock() self.ctxt = context.Context('fake_user', 'fake_tenant') self.policy_data = { @@ -69,7 +68,8 @@ class TestQosPlugin(base.BaseQosTestCase): self.ctxt, **self.rule_data['bandwidth_limit_rule']) def _validate_notif_driver_params(self, method_name): - method = getattr(self.notif_driver_m, method_name) + method = getattr(self.qos_plugin.notification_driver_manager, + method_name) self.assertTrue(method.called) self.assertIsInstance( method.call_args[0][1], policy_object.QosPolicy)