Skip to content

Commit f0d86b8

Browse files
committed
Fix ExcInfo.value printed as source code
1 parent 76b8870 commit f0d86b8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/_pytest/_code/code.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,11 @@ def _write_entry_lines(self, tw: TerminalWriter) -> None:
12211221
if not self.lines:
12221222
return
12231223

1224+
if self.style == "value":
1225+
for line in self.lines:
1226+
tw.line(line)
1227+
return
1228+
12241229
# separate indents and source lines that are not failures: we want to
12251230
# highlight the code but not the indentation, which may contain markers
12261231
# such as "> assert 0"
@@ -1236,11 +1241,8 @@ def _write_entry_lines(self, tw: TerminalWriter) -> None:
12361241
failure_lines.extend(self.lines[index:])
12371242
break
12381243
else:
1239-
if self.style == "value":
1240-
source_lines.append(line)
1241-
else:
1242-
indents.append(line[:indent_size])
1243-
source_lines.append(line[indent_size:])
1244+
indents.append(line[:indent_size])
1245+
source_lines.append(line[indent_size:])
12441246

12451247
tw._write_source(source_lines, indents)
12461248

0 commit comments

Comments
 (0)