Enable fatal exceptions during tests
This allows tests to catch string format errors in exception messages. Change-Id: I66d0363c02ef99482d4bec27b90584f8cea80e7a
This commit is contained in:
@@ -29,6 +29,7 @@ import testtools
|
||||
|
||||
from neutron_lib._i18n import _
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
|
||||
from neutron_lib.tests import _post_mortem_debug as post_mortem_debug
|
||||
from neutron_lib.tests import _tools as tools
|
||||
@@ -117,6 +118,11 @@ class BaseTestCase(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(BaseTestCase, self).setUp()
|
||||
|
||||
# Enabling 'use_fatal_exceptions' allows us to catch string
|
||||
# substitution format errors in exception messages.
|
||||
mock.patch.object(exceptions.NeutronException, 'use_fatal_exceptions',
|
||||
return_value=True).start()
|
||||
|
||||
# Update the default QueuePool parameters. These can be tweaked by the
|
||||
# conf variables - max_pool_size, max_overflow and pool_timeout
|
||||
db_options.set_defaults(
|
||||
|
||||
@@ -36,7 +36,6 @@ class TestExceptions(base.BaseTestCase):
|
||||
raise_exc_class = functools.partial(_raise, exc_class)
|
||||
e = self.assertRaises(exc_class, raise_exc_class, **kwargs)
|
||||
self.assertEqual(expected_msg, str(e))
|
||||
self.assertFalse(e.use_fatal_exceptions())
|
||||
|
||||
def test_base(self):
|
||||
self._check_nexc(
|
||||
@@ -64,7 +63,7 @@ class TestExceptions(base.BaseTestCase):
|
||||
self._check_nexc(
|
||||
ne.BadRequest,
|
||||
_('Bad A request: B.'),
|
||||
bad_resource='A', bad_msg='B')
|
||||
resource='A', msg='B')
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user