Skip to content

Commit 6e7917c

Browse files
committed
Don't break into pdb for raise unittest.SkipTest()
1 parent 15ac034 commit 6e7917c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/_pytest/debugging.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import functools
44
import sys
55
import types
6+
import unittest
67
from typing import Any
78
from typing import Callable
89
from typing import Generator
@@ -293,7 +294,9 @@ def pytest_exception_interact(
293294
sys.stdout.write(out)
294295
sys.stdout.write(err)
295296
assert call.excinfo is not None
296-
_enter_pdb(node, call.excinfo, report)
297+
298+
if not isinstance(call.excinfo.value, unittest.SkipTest):
299+
_enter_pdb(node, call.excinfo, report)
297300

298301
def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None:
299302
tb = _postmortem_traceback(excinfo)

testing/test_debugging.py

+12
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ def test_func():
123123
)
124124
assert rep.skipped
125125
assert len(pdblist) == 0
126+
127+
def test_pdb_on_raise_skiptest(self, pytester, pdblist) -> None:
128+
rep = runpdb_and_get_report(
129+
pytester,
130+
"""
131+
import unittest
132+
133+
raise unittest.SkipTest("This is a common way to skip an entire file.")
134+
""",
135+
)
136+
assert rep.skipped
137+
assert len(pdblist) == 0
126138

127139
def test_pdb_on_BdbQuit(self, pytester, pdblist) -> None:
128140
rep = runpdb_and_get_report(

0 commit comments

Comments
 (0)