From 0f588ac59b998a8a12457ffdca87292d67a0584a Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Fri, 10 Jul 2015 13:20:16 +0200 Subject: [PATCH] Fix tests failing in gate gate-cinder-python27 gate-cinder-python34 is reporting failures where it wasn't before. This is all due to new mock version 1.1.0. This patch fixed the tests to pass the gate. Some of these errors are actual errors in our test code, while other are changes to Mock syntax. Closes-Bug: #1473454 Change-Id: If8eabfeacacc221e92dfece9f4937875bd70751e --- cinder/test.py | 2 +- cinder/tests/unit/targets/test_iet_driver.py | 10 +++++----- cinder/tests/unit/test_pure.py | 4 ++-- cinder/tests/unit/test_test.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cinder/test.py b/cinder/test.py index ce101d3f5..c8433d126 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -106,7 +106,7 @@ def _patch_mock_to_raise_for_invalid_assert_calls(): 'assert_called_with', 'assert_called_once_with', 'assert_has_calls', - 'assert_any_calls'] + 'assert_any_call'] if name.startswith('assert') and name not in valid_asserts: raise AttributeError('%s is not a valid mock assert method' diff --git a/cinder/tests/unit/targets/test_iet_driver.py b/cinder/tests/unit/targets/test_iet_driver.py index 9f6921bbe..92e8a4ea3 100644 --- a/cinder/tests/unit/targets/test_iet_driver.py +++ b/cinder/tests/unit/targets/test_iet_driver.py @@ -157,11 +157,11 @@ class TestIetAdmDriver(tf.TargetDriverFixture): 0, self.testvol['id'], self.testvol['name']) - mock_execute.assert_any_calls('ietadm', - '--op', - 'delete', - '--tid=1', - run_as_root=True) + mock_execute.assert_any_call('ietadm', + '--op', + 'delete', + '--tid=1', + run_as_root=True) # Test the failure case: putils.ProcessExecutionError mock_execute.side_effect = putils.ProcessExecutionError diff --git a/cinder/tests/unit/test_pure.py b/cinder/tests/unit/test_pure.py index 075faafaa..98594eecc 100644 --- a/cinder/tests/unit/test_pure.py +++ b/cinder/tests/unit/test_pure.py @@ -205,8 +205,8 @@ class PureDriverTestCase(test.TestCase): """ func(*args, **kwargs) for mock_func in mocks: - mock_func.side_effect = exception.PureDriverException( - reason="reason") + mock_func.side_effect = [exception.PureDriverException( + reason='reason')] self.assertRaises(exception.PureDriverException, func, *args, **kwargs) mock_func.side_effect = None diff --git a/cinder/tests/unit/test_test.py b/cinder/tests/unit/test_test.py index 1078c8e73..fb15b09d7 100644 --- a/cinder/tests/unit/test_test.py +++ b/cinder/tests/unit/test_test.py @@ -55,12 +55,12 @@ class MockAssertTestCase(test.TestCase): mock_call(2) mock_call.assert_has_calls([mock.call(1), mock.call(2)]) - def test_assert_any_calls(self): + def test_assert_any_call(self): mock_call = mock.MagicMock(return_value=None) mock_call(1) mock_call(2) mock_call(3) - mock_call.assert_any_calls([mock.call(1)]) + mock_call.assert_any_call(1) def test_assert_called_with(self): mock_call = mock.MagicMock(return_value=None) -- 2.45.2