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
This commit is contained in:
Miguel Ángel Ajo 2014-11-28 18:00:04 +01:00 committed by Miguel Angel Ajo
parent 988bd650d2
commit 13120bbd27
2 changed files with 10 additions and 12 deletions

View File

@ -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):

View File

@ -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)