Merge pull request #3152 from brianmaissy/silently_fail_to_import_during_postmortem
If we fail to import doctest.UnexpectedException during postmortem, fail quietly
This commit is contained in:
commit
7c80c81433
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import pdb
|
import pdb
|
||||||
import sys
|
import sys
|
||||||
|
from doctest import UnexpectedException
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
|
@ -95,10 +96,9 @@ def _enter_pdb(node, excinfo, rep):
|
||||||
|
|
||||||
|
|
||||||
def _postmortem_traceback(excinfo):
|
def _postmortem_traceback(excinfo):
|
||||||
# A doctest.UnexpectedException is not useful for post_mortem.
|
|
||||||
# Use the underlying exception instead:
|
|
||||||
from doctest import UnexpectedException
|
|
||||||
if isinstance(excinfo.value, UnexpectedException):
|
if isinstance(excinfo.value, UnexpectedException):
|
||||||
|
# A doctest.UnexpectedException is not useful for post_mortem.
|
||||||
|
# Use the underlying exception instead:
|
||||||
return excinfo.value.exc_info[2]
|
return excinfo.value.exc_info[2]
|
||||||
else:
|
else:
|
||||||
return excinfo._excinfo[2]
|
return excinfo._excinfo[2]
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Move import of ``doctest.UnexpectedException`` to top-level to avoid possible errors when using ``--pdb``.
|
Loading…
Reference in New Issue