From 3947faca85c221f3373840bf1ab54b20a8fed4c6 Mon Sep 17 00:00:00 2001 From: Michal Dulko Date: Wed, 11 Mar 2015 10:36:38 +0100 Subject: [PATCH] Remove global mocking from test_pure.py Tests for pure driver are patching cinder.utils.retry globally. All tests running after test_pure got imported have retry decorator already mocked. This creates problems when writing new unit tests involving the decorator. This change unpatches cinder.utils.retry after test_pure imports pure driver. Change-Id: Ie9cbe6ffb3cfcaba5a296b5083974696117b99bb Closes-Bug: 1430699 --- cinder/tests/test_pure.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cinder/tests/test_pure.py b/cinder/tests/test_pure.py index 3cb4289e4..7b3e22e43 100644 --- a/cinder/tests/test_pure.py +++ b/cinder/tests/test_pure.py @@ -28,10 +28,14 @@ def fake_retry(exceptions, interval=1, retries=3, backoff_rate=2): return f return _decorator -mock.patch('cinder.utils.retry', fake_retry).start() +patch_retry = mock.patch('cinder.utils.retry', fake_retry) +patch_retry.start() sys.modules['purestorage'] = mock.Mock() from cinder.volume.drivers import pure +# Only mock utils.retry for cinder.volume.drivers.pure import +patch_retry.stop() + DRIVER_PATH = "cinder.volume.drivers.pure" DRIVER_OBJ = DRIVER_PATH + ".PureISCSIDriver" ARRAY_OBJ = DRIVER_PATH + ".FlashArray" -- 2.45.2