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:
Ronny Pfannschmidt 2018-02-05 10:04:00 +01:00 committed by GitHub
commit 7c80c81433
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@
from __future__ import absolute_import, division, print_function
import pdb
import sys
from doctest import UnexpectedException
def pytest_addoption(parser):
@ -95,10 +96,9 @@ def _enter_pdb(node, excinfo, rep):
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):
# A doctest.UnexpectedException is not useful for post_mortem.
# Use the underlying exception instead:
return excinfo.value.exc_info[2]
else:
return excinfo._excinfo[2]

1
changelog/1810.bugfix Normal file
View File

@ -0,0 +1 @@
Move import of ``doctest.UnexpectedException`` to top-level to avoid possible errors when using ``--pdb``.