From bf1313a43f9a24da6386d4cf9dd2f3b60ba44d0f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 12 Aug 2016 00:57:29 +0200 Subject: [PATCH] Improve display of continuation lines with multiline errors Fixes https://github.com/pytest-dev/pytest/issues/717. Follow-up to https://github.com/pytest-dev/pytest/pull/1762. --- _pytest/python.py | 10 ++++------ testing/python/fixture.py | 9 +++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index dea7b58ce7e..20277d6e498 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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)) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 8b0a203bd5a..7264934a4cf 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -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()