Browse Source

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
changes/33/137833/3
Miguel Ángel Ajo 7 years ago
committed by Miguel Angel Ajo
parent
commit
13120bbd27
  1. 20
      neutron/tests/post_mortem_debug.py
  2. 2
      neutron/tests/unit/test_post_mortem_debug.py

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

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

Loading…
Cancel
Save