Skip to content

Commit d0eb86c

Browse files
Prevent hiding underlying exception when ConfTestImportFailure is raised
1 parent 4a1557f commit d0eb86c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

changelog/7150.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.

src/_pytest/debugging.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55

66
from _pytest import outcomes
7+
from _pytest.config import ConftestImportFailure
78
from _pytest.config import hookimpl
89
from _pytest.config.exceptions import UsageError
910

@@ -338,6 +339,10 @@ def _postmortem_traceback(excinfo):
338339
# A doctest.UnexpectedException is not useful for post_mortem.
339340
# Use the underlying exception instead:
340341
return excinfo.value.exc_info[2]
342+
elif isinstance(excinfo.value, ConftestImportFailure):
343+
# A config.ConftestImportFailure is not useful for post_mortem.
344+
# Use the underlying exception instead:
345+
return excinfo.value.excinfo[2]
341346
else:
342347
return excinfo._excinfo[2]
343348

0 commit comments

Comments
 (0)