]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove global mocking from test_pure.py
authorMichal Dulko <michal.dulko@intel.com>
Wed, 11 Mar 2015 09:36:38 +0000 (10:36 +0100)
committerMichal Dulko <michal.dulko@intel.com>
Wed, 11 Mar 2015 09:36:38 +0000 (10:36 +0100)
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

index 3cb4289e4ad27f00ddbbc5972e91399cc583262a..7b3e22e43f2c88abb06e97634c5668ffc6b45e4c 100644 (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"