Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to pytest_report_teststatus #4688

Merged
merged 2 commits into from Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/4688.feature.rst
@@ -0,0 +1 @@
``pytest_report_teststatus`` hook now can also receive a ``config`` parameter.
4 changes: 3 additions & 1 deletion src/_pytest/hookspec.py
Expand Up @@ -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` """


Expand Down
4 changes: 3 additions & 1 deletion src/_pytest/resultlog.py
Expand Up @@ -66,7 +66,9 @@ def log_outcome(self, report, lettercode, longrepr):
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)
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/terminal.py
Expand Up @@ -363,7 +363,7 @@ def pytest_runtest_logstart(self, nodeid, location):

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
Expand Down