forked from pool/python-pytest-instafail
* pytest42.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-instafail?expand=0&rev=7
32 lines
1.3 KiB
Diff
32 lines
1.3 KiB
Diff
From eb4ff5e5cf1811ebde34e070520142647c907726 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Hahler <git@thequod.de>
|
|
Date: Thu, 14 Feb 2019 17:12:51 +0100
|
|
Subject: [PATCH] print_failure: fix compatibility with pytest 4.2
|
|
|
|
Fixes https://github.com/pytest-dev/pytest-instafail/issues/14.
|
|
---
|
|
pytest_instafail.py | 8 +++++---
|
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/pytest_instafail.py b/pytest_instafail.py
|
|
index 495f901..1a4530c 100644
|
|
--- a/pytest_instafail.py
|
|
+++ b/pytest_instafail.py
|
|
@@ -76,11 +76,13 @@ def print_failure(self, report):
|
|
self.write_line(line)
|
|
else:
|
|
msg = self._getfailureheadline(report)
|
|
- if not hasattr(report, 'when'):
|
|
+ # "when" was unset before pytest 4.2 for collection errors.
|
|
+ when = getattr(report, "when", "collect")
|
|
+ if when == "collect":
|
|
msg = "ERROR collecting " + msg
|
|
- elif report.when == "setup":
|
|
+ elif when == "setup":
|
|
msg = "ERROR at setup of " + msg
|
|
- elif report.when == "teardown":
|
|
+ elif when == "teardown":
|
|
msg = "ERROR at teardown of " + msg
|
|
self.write_sep("_", msg)
|
|
if not self.config.getvalue("usepdb"):
|