1616from typing import TYPE_CHECKING
1717from typing import TypeVar
1818
19+ from .config import Config
1920from .reports import BaseReport
2021from .reports import CollectErrorRepr
2122from .reports import CollectReport
@@ -239,11 +240,11 @@ def call_and_report(
239240 runtest_hook = ihook .pytest_runtest_teardown
240241 else :
241242 assert False , f"Unhandled runtest hook case: { when } "
242- reraise : tuple [type [BaseException ], ...] = (Exit ,)
243- if not item .config .getoption ("usepdb" , False ):
244- reraise += (KeyboardInterrupt ,)
243+
245244 call = CallInfo .from_call (
246- lambda : runtest_hook (item = item , ** kwds ), when = when , reraise = reraise
245+ lambda : runtest_hook (item = item , ** kwds ),
246+ when = when ,
247+ reraise = get_reraise_exceptions (item .config ),
247248 )
248249 report : TestReport = ihook .pytest_runtest_makereport (item = item , call = call )
249250 if log :
@@ -253,6 +254,14 @@ def call_and_report(
253254 return report
254255
255256
257+ def get_reraise_exceptions (config : Config ) -> tuple [type [BaseException ], ...]:
258+ """Return exception types that should not be suppressed in general."""
259+ reraise : tuple [type [BaseException ], ...] = (Exit ,)
260+ if not config .getoption ("usepdb" , False ):
261+ reraise += (KeyboardInterrupt ,)
262+ return reraise
263+
264+
256265def check_interactive_exception (call : CallInfo [object ], report : BaseReport ) -> bool :
257266 """Check whether the call raised an exception that should be reported as
258267 interactive."""
0 commit comments