From f826106941b34047dfa3149f3959b2ccc81db930 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 2 Nov 2019 10:24:16 +0100 Subject: [PATCH 1/2] [experimental] cacheprovider: store repr of reports with last-failed This is meant to aid debugging, e.g. in case there are suddenly a lot of last-failed tests. Ref: https://github.com/pytest-dev/pytest/issues/5301 Works better with: https://github.com/blueyed/pytest/pull/54 --- src/_pytest/cacheprovider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index a0a88621f78..7a476bccc34 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -191,7 +191,7 @@ def pytest_runtest_logreport(self, report): if (report.when == "call" and report.passed) or report.skipped: self.lastfailed.pop(report.nodeid, None) elif report.failed: - self.lastfailed[report.nodeid] = True + self.lastfailed[report.nodeid] = repr(report) def pytest_collectreport(self, report): passed = report.outcome in ("passed", "skipped") From 54223ec30d0191043799ee0ed0ff8d03be1d0cc6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 2 Nov 2019 11:34:33 +0100 Subject: [PATCH 2/2] fixup! [experimental] cacheprovider: store repr of reports with last-failed --- src/_pytest/cacheprovider.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 7a476bccc34..2daa7f082c3 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -191,7 +191,12 @@ def pytest_runtest_logreport(self, report): if (report.when == "call" and report.passed) or report.skipped: self.lastfailed.pop(report.nodeid, None) elif report.failed: - self.lastfailed[report.nodeid] = repr(report) + info = [repr(report)] + try: + info.append(str(report.longrepr.reprcrash)) + except AttributeError: + info.append(str(report.longrepr)) + self.lastfailed[report.nodeid] = info def pytest_collectreport(self, report): passed = report.outcome in ("passed", "skipped")