Merge pull request #4688 from nicoddemus/add-config-to-hooks
Add config to pytest_report_teststatus
This commit is contained in:
1
changelog/4688.feature.rst
Normal file
1
changelog/4688.feature.rst
Normal file
@@ -0,0 +1 @@
|
||||
``pytest_report_teststatus`` hook now can also receive a ``config`` parameter.
|
||||
@@ -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` """
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user