Remove "patch mock to raise for invalid assert calls"

This looks like it's causing problems with a new
mock 2.0.0 release, proposing to just remove it to
keep things working.

Closes-Bug: #1567079
Change-Id: I2a82eec20f8099c0651a21ac7aed1a0771ef5297
This commit is contained in:
Eric Harney 2016-04-06 17:02:08 -04:00
parent b4b0c96c68
commit d21b934718
2 changed files with 0 additions and 29 deletions

View File

@ -101,29 +101,6 @@ class Database(fixtures.Fixture):
os.path.join(CONF.state_path, self.sqlite_db))
def _patch_mock_to_raise_for_invalid_assert_calls():
def raise_for_invalid_assert_calls(wrapped):
def wrapper(_self, name):
valid_asserts = [
'assert_called_with',
'assert_called_once_with',
'assert_has_calls',
'assert_any_call']
if name.startswith('assert') and name not in valid_asserts:
raise AttributeError('%s is not a valid mock assert method'
% name)
return wrapped(_self, name)
return wrapper
mock.Mock.__getattr__ = raise_for_invalid_assert_calls(
mock.Mock.__getattr__)
# NOTE(gibi): needs to be called only once at import time
# to patch the mock lib
_patch_mock_to_raise_for_invalid_assert_calls()
class TestCase(testtools.TestCase):
"""Test case base class for all unit tests."""

View File

@ -71,9 +71,3 @@ class MockAssertTestCase(test.TestCase):
mock_call = mock.MagicMock(return_value=None)
mock_call(1, 'foobar', a='123')
mock_call.assert_called_once_with(1, 'foobar', a='123')
def test_invalid_assert_calls(self):
mock_call = mock.MagicMock()
self.assertRaises(AttributeError, lambda: mock_call.assert_called)
self.assertRaises(AttributeError,
lambda: mock_call.assert_once_called_with)