code: make TracebackEntry immutable

TracebackEntry being mutable caught me by surprise and makes reasoning
about the exception formatting code harder. Make it a proper value.
This commit is contained in:
Ran Benita
2023-04-12 22:58:57 +03:00
parent 0a20452f78
commit 6f7f89f3c4
3 changed files with 20 additions and 10 deletions

View File

@@ -1122,8 +1122,10 @@ raise ValueError()
)
excinfo = pytest.raises(ValueError, mod.f)
excinfo.traceback = excinfo.traceback.filter(excinfo)
excinfo.traceback[1].set_repr_style("short")
excinfo.traceback[2].set_repr_style("short")
excinfo.traceback = _pytest._code.Traceback(
entry if i not in (1, 2) else entry.with_repr_style("short")
for i, entry in enumerate(excinfo.traceback)
)
r = excinfo.getrepr(style="long")
r.toterminal(tw_mock)
for line in tw_mock.lines: