From: Miguel Ángel Ajo Date: Fri, 28 Nov 2014 17:00:04 +0000 (+0100) Subject: Cleanup recent generalization in post mortem debugger X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=13120bbd27bf0f6353b64e8c202525914b8dce3b;p=openstack-build%2Fneutron-build.git Cleanup recent generalization in post mortem debugger Remove unnecessary default arguments and constants in the post mortem debugger code. Also remove exception internationalization in testing code. Change-Id: I66ba3248a7ff502fa92e1c46f40e280c503524a2 --- diff --git a/neutron/tests/post_mortem_debug.py b/neutron/tests/post_mortem_debug.py index 8e6ac61a2..cecf44fdd 100644 --- a/neutron/tests/post_mortem_debug.py +++ b/neutron/tests/post_mortem_debug.py @@ -16,25 +16,23 @@ import functools import traceback -DEFAULT_DEBUGGER = 'pdb' - -def get_exception_handler(debugger_name=None): - debugger = _get_debugger(debugger_name or DEFAULT_DEBUGGER) +def get_exception_handler(debugger_name): + debugger = _get_debugger(debugger_name) return functools.partial(_exception_handler, debugger) def _get_debugger(debugger_name): try: debugger = __import__(debugger_name) - if 'post_mortem' in dir(debugger): - return debugger except ImportError: - raise ValueError( - _("can't import %s module as a post mortem debugger") % - debugger_name) - raise ValueError( - _("%s is not a supported post mortem debugger") % debugger_name) + raise ValueError("can't import %s module as a post mortem debugger" % + debugger_name) + if 'post_mortem' in dir(debugger): + return debugger + else: + raise ValueError("%s is not a supported post mortem debugger" % + debugger_name) def _exception_handler(debugger, exc_info): diff --git a/neutron/tests/unit/test_post_mortem_debug.py b/neutron/tests/unit/test_post_mortem_debug.py index 3237558c1..1d940f4fa 100644 --- a/neutron/tests/unit/test_post_mortem_debug.py +++ b/neutron/tests/unit/test_post_mortem_debug.py @@ -34,7 +34,7 @@ class TestTesttoolsExceptionHandler(base.BaseTestCase): with mock.patch.object(post_mortem_debug, 'get_ignored_traceback', return_value=mock.Mock()): - post_mortem_debug.get_exception_handler()(exc_info) + post_mortem_debug.get_exception_handler('pdb')(exc_info) # traceback will become post_mortem_debug.FilteredTraceback filtered_exc_info = (exc_info[0], exc_info[1], mock.ANY)