summaryrefslogtreecommitdiff
path: root/src/_pytest/debugging.py
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2020-06-08 16:08:46 +0300
committerRan Benita <ran@unusedvar.com>2020-06-12 17:34:31 +0300
commit0256cb3aae7221909244d187ed912716fcc5aa5e (patch)
tree1be4b11f8d2b752b9795d7144d75fe3c02e74c93 /src/_pytest/debugging.py
parent7081ed19b892a799e1dea99a7922cab79fefc1df (diff)
downloadpytest-0256cb3aae7221909244d187ed912716fcc5aa5e.tar.gz
hookspec: type annotate pytest_internalerror
Also switch to using ExceptionRepr instead of `Union[ReprExceptionInfo, ExceptionChainRepr]` which is somewhat annoying and less future proof.
Diffstat (limited to 'src/_pytest/debugging.py')
-rw-r--r--src/_pytest/debugging.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py
index 3001db4ec..0567927c0 100644
--- a/src/_pytest/debugging.py
+++ b/src/_pytest/debugging.py
@@ -2,11 +2,13 @@
import argparse
import functools
import sys
+import types
from typing import Generator
from typing import Tuple
from typing import Union
from _pytest import outcomes
+from _pytest._code import ExceptionInfo
from _pytest.compat import TYPE_CHECKING
from _pytest.config import Config
from _pytest.config import ConftestImportFailure
@@ -280,9 +282,10 @@ class PdbInvoke:
out, err = capman.read_global_capture()
sys.stdout.write(out)
sys.stdout.write(err)
+ assert call.excinfo is not None
_enter_pdb(node, call.excinfo, report)
- def pytest_internalerror(self, excrepr, excinfo) -> None:
+ def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None:
tb = _postmortem_traceback(excinfo)
post_mortem(tb)
@@ -320,7 +323,9 @@ def maybe_wrap_pytest_function_for_tracing(pyfuncitem):
wrap_pytest_function_for_tracing(pyfuncitem)
-def _enter_pdb(node: Node, excinfo, rep: BaseReport) -> BaseReport:
+def _enter_pdb(
+ node: Node, excinfo: ExceptionInfo[BaseException], rep: BaseReport
+) -> BaseReport:
# XXX we re-use the TerminalReporter's terminalwriter
# because this seems to avoid some encoding related troubles
# for not completely clear reasons.
@@ -349,7 +354,7 @@ def _enter_pdb(node: Node, excinfo, rep: BaseReport) -> BaseReport:
return rep
-def _postmortem_traceback(excinfo):
+def _postmortem_traceback(excinfo: ExceptionInfo[BaseException]) -> types.TracebackType:
from doctest import UnexpectedException
if isinstance(excinfo.value, UnexpectedException):
@@ -361,10 +366,11 @@ def _postmortem_traceback(excinfo):
# Use the underlying exception instead:
return excinfo.value.excinfo[2]
else:
+ assert excinfo._excinfo is not None
return excinfo._excinfo[2]
-def post_mortem(t) -> None:
+def post_mortem(t: types.TracebackType) -> None:
p = pytestPDB._init_pdb("post_mortem")
p.reset()
p.interaction(None, t)