/usr/lib/imh-dnskeyapi/venv/lib/python3.13/site-packages/_pytest
NameSizeModeActions
assertion/-0755rm
config/-0755rm
mark/-0755rm
_code/-0755rm
_io/-0755rm
_py/-0755rm
cacheprovider.py223730644editdlrm
capture.py353300644editdlrm
compat.py114670644editdlrm
debugging.py132600644editdlrm
deprecated.py31470644editdlrm
doctest.py262550644editdlrm
faulthandler.py36740644editdlrm
fixtures.py735500644editdlrm
freeze_support.py12910644editdlrm
helpconfig.py88950644editdlrm
hookspec.py428310644editdlrm
junitxml.py255740644editdlrm
legacypath.py165880644editdlrm
logging.py351240644editdlrm
main.py374160644editdlrm
monkeypatch.py145980644editdlrm
nodes.py264830644editdlrm
outcomes.py105320644editdlrm
pastebin.py39780644editdlrm
pathlib.py375690644editdlrm
py.typed00644editdlrm
pytester.py615520644editdlrm
pytester_assertions.py22440644editdlrm
python.py648510644editdlrm
python_api.py401220644editdlrm
python_path.py7450644editdlrm
recwarn.py132270644editdlrm
reports.py213310644editdlrm
runner.py194360644editdlrm
scope.py27980644editdlrm
setuponly.py33060644editdlrm
setupplan.py11840644editdlrm
skipping.py102170644editdlrm
stash.py30900644editdlrm
stepwise.py45960644editdlrm
terminal.py573930644editdlrm
threadexception.py30050644editdlrm
timing.py4130644editdlrm
tmpdir.py113750644editdlrm
unittest.py156140644editdlrm
unraisableexception.py32520644editdlrm
warnings.py52110644editdlrm
warning_types.py43880644editdlrm
_argcomplete.py37760644editdlrm
_version.py5110644editdlrm
__init__.py3910644editdlrm
Edit: /usr/lib/imh-dnskeyapi/venv/lib/python3.13/site-packages/_pytest/threadexception.py (3005B)
from __future__ import annotations import threading import traceback from types import TracebackType from typing import Any from typing import Callable from typing import Generator from typing import TYPE_CHECKING import warnings import pytest if TYPE_CHECKING: from typing_extensions import Self # Copied from cpython/Lib/test/support/threading_helper.py, with modifications. class catch_threading_exception: """Context manager catching threading.Thread exception using threading.excepthook. Storing exc_value using a custom hook can create a reference cycle. The reference cycle is broken explicitly when the context manager exits. Storing thread using a custom hook can resurrect it if it is set to an object which is being finalized. Exiting the context manager clears the stored object. Usage: with threading_helper.catch_threading_exception() as cm: # code spawning a thread which raises an exception ... # check the thread exception: use cm.args ... # cm.args attribute no longer exists at this point # (to break a reference cycle) """ def __init__(self) -> None: self.args: threading.ExceptHookArgs | None = None self._old_hook: Callable[[threading.ExceptHookArgs], Any] | None = None def _hook(self, args: threading.ExceptHookArgs) -> None: self.args = args def __enter__(self) -> Self: self._old_hook = threading.excepthook threading.excepthook = self._hook return self def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> None: assert self._old_hook is not None threading.excepthook = self._old_hook self._old_hook = None del self.args def thread_exception_runtest_hook() -> Generator[None]: with catch_threading_exception() as cm: try: yield finally: if cm.args: thread_name = ( "" if cm.args.thread is None else cm.args.thread.name ) msg = f"Exception in thread {thread_name}\n\n" msg += "".join( traceback.format_exception( cm.args.exc_type, cm.args.exc_value, cm.args.exc_traceback, ) ) warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg)) @pytest.hookimpl(wrapper=True, trylast=True) def pytest_runtest_setup() -> Generator[None]: yield from thread_exception_runtest_hook() @pytest.hookimpl(wrapper=True, tryfirst=True) def pytest_runtest_call() -> Generator[None]: yield from thread_exception_runtest_hook() @pytest.hookimpl(wrapper=True, tryfirst=True) def pytest_runtest_teardown() -> Generator[None]: yield from thread_exception_runtest_hook()