Don't break into `pdb` for `raise unittest.SkipTest()`

This commit is contained in:
Gabriel Landau 2022-10-13 18:20:46 -04:00
parent 15ac0349b2
commit 6e7917c1a0
2 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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(