Skip to content

Commit bf1313a

Browse files
committed
Improve display of continuation lines with multiline errors
Fixes #717. Follow-up to #1762.
1 parent 34925a3 commit bf1313a

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

_pytest/python.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,12 +1849,10 @@ def toterminal(self, tw):
18491849
for tbline in self.tblines:
18501850
tw.line(tbline.rstrip())
18511851
lines = self.errorstring.split("\n")
1852-
for line in lines:
1853-
if line == lines[0]:
1854-
prefix = 'E '
1855-
else:
1856-
prefix = ' '
1857-
tw.line(prefix + line.strip(), red=True)
1852+
if lines:
1853+
tw.line('E ' + lines[0].strip(), red=True)
1854+
for line in lines[1:]:
1855+
tw.line('> ' + line.strip(), red=True)
18581856
tw.line()
18591857
tw.line("%s:%d" % (self.filename, self.firstlineno+1))
18601858

testing/python/fixture.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,11 @@ def test_lookup_error(unknown):
395395
""")
396396
result = testdir.runpytest()
397397
result.stdout.fnmatch_lines([
398-
"*ERROR*test_lookup_error*",
399-
"*def test_lookup_error(unknown):*",
400-
"*fixture*unknown*not found*",
401-
"*available fixtures*",
398+
"*ERROR at setup of test_lookup_error*",
399+
" def test_lookup_error(unknown):*",
400+
"E fixture 'unknown' not found",
401+
"> available fixtures:*",
402+
"> use 'py*test --fixtures *' for help on them.",
402403
"*1 error*",
403404
])
404405
assert "INTERNAL" not in result.stdout.str()

0 commit comments

Comments
 (0)