diff --git a/AUTHORS b/AUTHORS index b459cef6ce8..b5dc2eb1ead 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,6 +35,7 @@ David Díaz-Barquero David Mohr David Vierra Edison Gustavo Muenz +Edoardo Batini Eduardo Schettino Elizaveta Shashkova Endre Galaczi diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2e55acbbcf2..728c86ca316 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,9 @@ **Bug Fixes** +* Add an 'E' to the first line of error messages from FixtureLookupErrorRepr. + Fixes (`#717`_). Thanks `@blueyed`_ for reporting and `@eolo999`_ for the PR. + * Text documents without any doctests no longer appear as "skipped". Thanks `@graingert`_ for reporting and providing a full PR (`#1580`_). diff --git a/_pytest/python.py b/_pytest/python.py index 6242fd49782..cc2dd64d3df 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1835,8 +1835,13 @@ def toterminal(self, tw): #tw.line("FixtureLookupError: %s" %(self.argname), red=True) for tbline in self.tblines: tw.line(tbline.rstrip()) - for line in self.errorstring.split("\n"): - tw.line(" " + line.strip(), red=True) + lines = self.errorstring.split("\n") + for line in lines: + if line == lines[0]: + prefix = 'E ' + else: + prefix = ' ' + tw.line(prefix + line.strip(), red=True) tw.line() tw.line("%s:%d" % (self.filename, self.firstlineno+1)) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 1b14d12a5f6..8b7cca205cc 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -376,7 +376,7 @@ def test_foo(invalid_fixture): res = testdir.runpytest(p) res.stdout.fnmatch_lines([ "*source code not available*", - "*fixture 'invalid_fixture' not found", + "E*fixture 'invalid_fixture' not found", ]) def test_plugins_given_as_strings(self, tmpdir, monkeypatch): diff --git a/testing/test_capture.py b/testing/test_capture.py index 73660692b8e..ef561ab4fe5 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -416,9 +416,9 @@ def test_two(capfd, capsys): result = testdir.runpytest(p) result.stdout.fnmatch_lines([ "*ERROR*setup*test_one*", - "*capsys*capfd*same*time*", + "E*capsys*capfd*same*time*", "*ERROR*setup*test_two*", - "*capsys*capfd*same*time*", + "E*capsys*capfd*same*time*", "*2 error*"]) @pytest.mark.parametrize("method", ["sys", "fd"])