code: do not truncate args when running with -vvv (#12241)
Related to #2871.
This commit is contained in:
@@ -11,6 +11,7 @@ import re
|
||||
import sys
|
||||
import textwrap
|
||||
from typing import Any
|
||||
from typing import cast
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import _pytest._code
|
||||
@@ -712,6 +713,29 @@ raise ValueError()
|
||||
assert full_reprlocals.lines
|
||||
assert full_reprlocals.lines[0] == "l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
||||
|
||||
def test_repr_args_not_truncated(self, importasmod) -> None:
|
||||
mod = importasmod(
|
||||
"""
|
||||
def func1(m):
|
||||
raise ValueError("hello\\nworld")
|
||||
"""
|
||||
)
|
||||
excinfo = pytest.raises(ValueError, mod.func1, "m" * 500)
|
||||
excinfo.traceback = excinfo.traceback.filter(excinfo)
|
||||
entry = excinfo.traceback[-1]
|
||||
p = FormattedExcinfo(funcargs=True, truncate_args=True)
|
||||
reprfuncargs = p.repr_args(entry)
|
||||
assert reprfuncargs is not None
|
||||
arg1 = cast(str, reprfuncargs.args[0][1])
|
||||
assert len(arg1) < 500
|
||||
assert "..." in arg1
|
||||
# again without truncate
|
||||
p = FormattedExcinfo(funcargs=True, truncate_args=False)
|
||||
reprfuncargs = p.repr_args(entry)
|
||||
assert reprfuncargs is not None
|
||||
assert reprfuncargs.args[0] == ("m", repr("m" * 500))
|
||||
assert "..." not in cast(str, reprfuncargs.args[0][1])
|
||||
|
||||
def test_repr_tracebackentry_lines(self, importasmod) -> None:
|
||||
mod = importasmod(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user