File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ Prevent hiding the underlying exception when ``ConfTestImportFailure `` is raised.
Original file line number Diff line number Diff line change 4
4
import sys
5
5
6
6
from _pytest import outcomes
7
+ from _pytest .config import ConftestImportFailure
7
8
from _pytest .config import hookimpl
8
9
from _pytest .config .exceptions import UsageError
9
10
@@ -338,6 +339,10 @@ def _postmortem_traceback(excinfo):
338
339
# A doctest.UnexpectedException is not useful for post_mortem.
339
340
# Use the underlying exception instead:
340
341
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 ]
341
346
else :
342
347
return excinfo ._excinfo [2 ]
343
348
Original file line number Diff line number Diff line change @@ -342,6 +342,15 @@ def pytest_runtest_protocol():
342
342
child .sendeof ()
343
343
self .flush (child )
344
344
345
+ def test_pdb_prevent_ConftestImportFailure_hiding_exception (self , testdir ):
346
+ testdir .makepyfile ("def test_func(): pass" )
347
+ sub_dir = testdir .tmpdir .join ("ns" ).ensure_dir ()
348
+ sub_dir .join ("conftest" ).new (ext = ".py" ).write ("import unknown" )
349
+ sub_dir .join ("test_file" ).new (ext = ".py" ).write ("def test_func(): pass" )
350
+
351
+ result = testdir .runpytest_subprocess ("--pdb" , "." )
352
+ result .stdout .fnmatch_lines (["-> import unknown" ])
353
+
345
354
def test_pdb_interaction_capturing_simple (self , testdir ):
346
355
p1 = testdir .makepyfile (
347
356
"""
You can’t perform that action at this time.
0 commit comments