From 5b09eb1d742a36b15318988df783204d4dee25eb Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 28 Jan 2019 19:00:50 -0200 Subject: [PATCH] Add config parameter to pytest_report_teststatus hook --- src/_pytest/hookspec.py | 4 +++- src/_pytest/resultlog.py | 4 +++- src/_pytest/terminal.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 2dfbfd0c9..4f346ba25 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -481,9 +481,11 @@ def pytest_report_collectionfinish(config, startdir, items): @hookspec(firstresult=True) -def pytest_report_teststatus(report): +def pytest_report_teststatus(report, config): """ return result-category, shortletter and verbose word for reporting. + :param _pytest.config.Config config: pytest config object + Stops at first non-None result, see :ref:`firstresult` """ diff --git a/src/_pytest/resultlog.py b/src/_pytest/resultlog.py index a2dd73094..cd3fde80f 100644 --- a/src/_pytest/resultlog.py +++ b/src/_pytest/resultlog.py @@ -66,7 +66,9 @@ class ResultLog(object): def pytest_runtest_logreport(self, report): if report.when != "call" and report.passed: return - res = self.config.hook.pytest_report_teststatus(report=report) + res = self.config.hook.pytest_report_teststatus( + report=report, config=self.config + ) code = res[1] if code == "x": longrepr = str(report.longrepr) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 9a0d7686e..3c6504b66 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -363,7 +363,7 @@ class TerminalReporter(object): def pytest_runtest_logreport(self, report): rep = report - res = self.config.hook.pytest_report_teststatus(report=rep) + res = self.config.hook.pytest_report_teststatus(report=rep, config=self.config) category, letter, word = res if isinstance(word, tuple): word, markup = word