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 functools
import sys import sys
import types import types
import unittest
from typing import Any from typing import Any
from typing import Callable from typing import Callable
from typing import Generator from typing import Generator
@ -293,6 +294,8 @@ class PdbInvoke:
sys.stdout.write(out) sys.stdout.write(out)
sys.stdout.write(err) sys.stdout.write(err)
assert call.excinfo is not None assert call.excinfo is not None
if not isinstance(call.excinfo.value, unittest.SkipTest):
_enter_pdb(node, call.excinfo, report) _enter_pdb(node, call.excinfo, report)
def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None: def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None:

View File

@ -124,6 +124,18 @@ class TestPDB:
assert rep.skipped assert rep.skipped
assert len(pdblist) == 0 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: def test_pdb_on_BdbQuit(self, pytester, pdblist) -> None:
rep = runpdb_and_get_report( rep = runpdb_and_get_report(
pytester, pytester,