Remove patching the mock lib

Since [1] was fixed we don't need to manually patch the mock lib to
avoid silently passing mistyped assert methods on mocks.

[1] https://bugs.python.org/issue21238

Change-Id: Iecf4dcf8e648c9191bf8846428683ec81812c026
This commit is contained in:
Balazs Gibizer 2018-08-10 10:55:52 +02:00
parent c049061bd4
commit d5284b6d97
1 changed files with 0 additions and 24 deletions

View File

@ -35,7 +35,6 @@ import pprint
import sys
import fixtures
import mock
from oslo_cache import core as cache
from oslo_concurrency import lockutils
from oslo_config import cfg
@ -152,29 +151,6 @@ class skipIf(object):
'classes')
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_calls']
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 NovaExceptionReraiseFormatError(object):
real_log_exception = exception.NovaException._log_exception