From 91624f1d7e9083d23e58dda2f1092b230e9476d5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 22 Apr 2024 13:26:37 +0200 Subject: [PATCH] add "verylong" traceback style --- src/_pytest/_code/code.py | 13 ++++++++----- src/_pytest/terminal.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 3b4a62a4f..ad4f5cbd9 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -55,7 +55,7 @@ from _pytest.pathlib import bestrelpath if sys.version_info[:2] < (3, 11): from exceptiongroup import BaseExceptionGroup -_TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"] +_TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto", "verylong"] class Code: @@ -836,11 +836,14 @@ class FormattedExcinfo: source = source.deindent() return source - def repr_args(self, entry: TracebackEntry) -> Optional["ReprFuncArgs"]: + def repr_args(self, entry: TracebackEntry, style=None) -> Optional["ReprFuncArgs"]: if self.funcargs: args = [] for argname, argvalue in entry.frame.getargs(var=True): - args.append((argname, saferepr(argvalue))) + if style == "verylong": + args.append((argname, saferepr(argvalue,maxsize=None))) + else: + args.append((argname, saferepr(argvalue))) return ReprFuncArgs(args) return None @@ -928,7 +931,7 @@ class FormattedExcinfo: if entry is not None and entry._repr_style is not None else self.style ) - if style in ("short", "long") and entry is not None: + if style in ("short", "long", "verylong") and entry is not None: source = self._getentrysource(entry) if source is None: source = Source("???") @@ -936,7 +939,7 @@ class FormattedExcinfo: else: line_index = entry.lineno - entry.getfirstlinesource() short = style == "short" - reprargs = self.repr_args(entry) if not short else None + reprargs = self.repr_args(entry, style) if not short else None s = self.get_source(source, line_index, excinfo, short=short) lines.extend(s) if short: diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 724d5c54d..a3889121e 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -213,7 +213,7 @@ def pytest_addoption(parser: Parser) -> None: action="store", dest="tbstyle", default="auto", - choices=["auto", "long", "short", "no", "line", "native"], + choices=["auto", "long", "short", "no", "line", "native", "verylong"], help="Traceback print mode (auto/long/short/line/native/no)", ) group._addoption( -- 2.43.0