Merge pull request #4688 from nicoddemus/add-config-to-hooks

Add config to pytest_report_teststatus
This commit is contained in:
Bruno Oliveira 2019-01-28 21:45:58 -02:00 committed by GitHub
commit 6aba60ab08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1 @@
``pytest_report_teststatus`` hook now can also receive a ``config`` parameter.

View File

@ -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` """

View File

@ -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)

View File

@ -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