Skip to content

Commit

Permalink
Improve display of continuation lines with multiline errors
Browse files Browse the repository at this point in the history
Fixes pytest-dev#717.
Follow-up to pytest-dev#1762.
  • Loading branch information
blueyed committed Aug 11, 2016
1 parent 34925a3 commit bf1313a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 4 additions & 6 deletions _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,12 +1849,10 @@ def toterminal(self, tw):
for tbline in self.tblines:
tw.line(tbline.rstrip())
lines = self.errorstring.split("\n")
for line in lines:
if line == lines[0]:
prefix = 'E '
else:
prefix = ' '
tw.line(prefix + line.strip(), red=True)
if lines:
tw.line('E ' + lines[0].strip(), red=True)
for line in lines[1:]:
tw.line('> ' + line.strip(), red=True)
tw.line()
tw.line("%s:%d" % (self.filename, self.firstlineno+1))

Expand Down
9 changes: 5 additions & 4 deletions testing/python/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,11 @@ def test_lookup_error(unknown):
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines([
"*ERROR*test_lookup_error*",
"*def test_lookup_error(unknown):*",
"*fixture*unknown*not found*",
"*available fixtures*",
"*ERROR at setup of test_lookup_error*",
" def test_lookup_error(unknown):*",
"E fixture 'unknown' not found",
"> available fixtures:*",
"> use 'py*test --fixtures *' for help on them.",
"*1 error*",
])
assert "INTERNAL" not in result.stdout.str()
Expand Down

0 comments on commit bf1313a

Please sign in to comment.