From: Michal Dulko Date: Wed, 11 Mar 2015 09:36:38 +0000 (+0100) Subject: Remove global mocking from test_pure.py X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3947faca85c221f3373840bf1ab54b20a8fed4c6;p=openstack-build%2Fcinder-build.git 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 --- 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"