Merge "Make NovaException format errors fatal for tests"

This commit is contained in:
Jenkins 2017-05-17 00:26:21 +00:00 committed by Gerrit Code Review
commit 3b2652a179

View File

@ -31,6 +31,7 @@ import datetime
import inspect
import os
import pprint
import sys
import fixtures
import mock
@ -49,6 +50,7 @@ import testtools
from nova import context
from nova import db
from nova import exception
from nova.network import manager as network_manager
from nova.network.security_group import openstack_driver
from nova import objects
@ -169,6 +171,26 @@ def _patch_mock_to_raise_for_invalid_assert_calls():
_patch_mock_to_raise_for_invalid_assert_calls()
class NovaExceptionReraiseFormatError(object):
real_log_exception = exception.NovaException._log_exception
@classmethod
def patch(cls):
exception.NovaException._log_exception = cls._wrap_log_exception
@staticmethod
def _wrap_log_exception(self):
exc_info = sys.exc_info()
NovaExceptionReraiseFormatError.real_log_exception(self)
six.reraise(*exc_info)
# NOTE(melwitt) This needs to be done at import time in order to also catch
# NovaException format errors that are in mock decorators. In these cases, the
# errors will be raised during test listing, before tests actually run.
NovaExceptionReraiseFormatError.patch()
class TestCase(testtools.TestCase):
"""Test case base class for all unit tests.