diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index b99c3fe2d..a3f80802c 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -3,6 +3,7 @@ import argparse import functools import sys import types +import unittest from typing import Any from typing import Callable from typing import Generator @@ -293,7 +294,9 @@ class PdbInvoke: sys.stdout.write(out) sys.stdout.write(err) assert call.excinfo is not None - _enter_pdb(node, call.excinfo, report) + + if not isinstance(call.excinfo.value, unittest.SkipTest): + _enter_pdb(node, call.excinfo, report) def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None: tb = _postmortem_traceback(excinfo) diff --git a/testing/test_debugging.py b/testing/test_debugging.py index 08ae09658..6761e61a9 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -123,6 +123,18 @@ class TestPDB: ) assert rep.skipped assert len(pdblist) == 0 + + def test_pdb_on_raise_skiptest(self, pytester, pdblist) -> None: + rep = runpdb_and_get_report( + pytester, + """ + import unittest + + raise unittest.SkipTest("This is a common way to skip an entire file.") + """, + ) + assert rep.skipped + assert len(pdblist) == 0 def test_pdb_on_BdbQuit(self, pytester, pdblist) -> None: rep = runpdb_and_get_report(