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
This commit is contained in:
Michal Dulko 2015-03-11 10:36:38 +01:00
parent 5b3ff204cc
commit 3947faca85
1 changed files with 5 additions and 1 deletions

View File

@ -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"