Skip to content

Commit 15ab2c7

Browse files
committed
runner: don't treat unittest.SkipTest as an interactive exception
Instead of special casing in the debugging plugin, it seems more correct to just not treat `unittest.SkipTest` as an interactive exception, similarly to pytest's own `Skipped`. The `pytest_make_collect_report` hook in runner.py already treats them the same. This fixes the issue more generally.
1 parent 3dc7d38 commit 15ab2c7

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

changelog/13917.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:class:`unittest.SkipTest` is no longer considered an interactive exception, i.e. :hook:`pytest_exception_interact` is no longer called for it.

src/_pytest/debugging.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,7 @@ def pytest_exception_interact(
294294
sys.stdout.write(out)
295295
sys.stdout.write(err)
296296
assert call.excinfo is not None
297-
298-
unittest = sys.modules.get("unittest")
299-
if unittest is None or not isinstance(call.excinfo.value, unittest.SkipTest):
300-
_enter_pdb(node, call.excinfo, report)
297+
_enter_pdb(node, call.excinfo, report)
301298

302299
def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None:
303300
exc_or_tb = _postmortem_exc_or_tb(excinfo)

src/_pytest/runner.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ def check_interactive_exception(call: CallInfo[object], report: BaseReport) -> b
271271
if hasattr(report, "wasxfail"):
272272
# Exception was expected.
273273
return False
274-
if isinstance(call.excinfo.value, Skipped | bdb.BdbQuit):
274+
unittest = sys.modules.get("unittest")
275+
if isinstance(call.excinfo.value, Skipped | bdb.BdbQuit) or (
276+
unittest is not None and isinstance(call.excinfo.value, unittest.SkipTest)
277+
):
275278
# Special control flow exception.
276279
return False
277280
return True

0 commit comments

Comments
 (0)