diff --git a/AUTHORS b/AUTHORS index 7ef2df84a..0d5e1bb64 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,6 +37,7 @@ David Vierra Diego Russo Dmitry Dygalo Edison Gustavo Muenz +Edoardo Batini Eduardo Schettino Elizaveta Shashkova Endre Galaczi diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c99947943..49294938e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,10 @@ **Bug Fixes** +* Add an 'E' to the first line of error messages from FixtureLookupErrorRepr. + Fixes `#717`_. Thanks `@blueyed`_ for reporting, `@eolo999`_ for the PR + and `@tomviner`_ for his guidance during EuroPython2016 sprint. + * Text documents without any doctests no longer appear as "skipped". Thanks `@graingert`_ for reporting and providing a full PR (`#1580`_). @@ -54,6 +58,7 @@ * Fixed collection of classes with custom ``__new__`` method. Fixes `#1579`_. Thanks to `@Stranger6667`_ for the PR. +.. _#717: https://github.com/pytest-dev/pytest/issues/717 .. _#1579: https://github.com/pytest-dev/pytest/issues/1579 .. _#1580: https://github.com/pytest-dev/pytest/pull/1580 .. _#1605: https://github.com/pytest-dev/pytest/issues/1605 @@ -66,6 +71,8 @@ .. _#925: https://github.com/pytest-dev/pytest/issues/925 .. _#1210: https://github.com/pytest-dev/pytest/issues/1210 +.. _@eolo999: https://github.com/eolo999 +.. _@blueyed: https://github.com/blueyed .. _@graingert: https://github.com/graingert .. _@taschini: https://github.com/taschini .. _@nikratio: https://github.com/nikratio diff --git a/_pytest/python.py b/_pytest/python.py index 812adf4b4..0f076a343 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1842,8 +1842,13 @@ class FixtureLookupErrorRepr(TerminalRepr): #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 1b14d12a5..8b7cca205 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -376,7 +376,7 @@ class TestGeneralUsage: 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 73660692b..ef561ab4f 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -416,9 +416,9 @@ class TestCaptureFixture: 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"])