From ce3fb9065efacdc9e8503f5ba630c4ba1b85855f Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Fri, 28 Aug 2015 07:49:28 +0200 Subject: [PATCH] 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 --- neutron/tests/unit/services/qos/test_qos_plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) -- 2.45.2