Skip to content

Commit

Permalink
Merge pull request #4691 from nicoddemus/config-terminal-summary-hook
Browse files Browse the repository at this point in the history
Add config to pytest_terminal_summary hook
  • Loading branch information
nicoddemus authored Jan 29, 2019
2 parents 3e0e819 + 7e8e593 commit b41dc03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/4691.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pytest_terminal_summary`` hook now can also receive a ``config`` parameter.
5 changes: 3 additions & 2 deletions src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,14 @@ def pytest_report_teststatus(report, config):
Stops at first non-None result, see :ref:`firstresult` """


def pytest_terminal_summary(terminalreporter, exitstatus):
def pytest_terminal_summary(terminalreporter, exitstatus, config):
"""Add a section to terminal summary reporting.
:param _pytest.terminal.TerminalReporter terminalreporter: the internal terminal reporter object
:param int exitstatus: the exit status that will be reported back to the OS
:param _pytest.config.Config config: pytest config object
.. versionadded:: 3.5
.. versionadded:: 4.2
The ``config`` parameter.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def pytest_sessionfinish(self, exitstatus):
)
if exitstatus in summary_exit_codes:
self.config.hook.pytest_terminal_summary(
terminalreporter=self, exitstatus=exitstatus
terminalreporter=self, exitstatus=exitstatus, config=self.config
)
if exitstatus == EXIT_INTERRUPTED:
self._report_keyboardinterrupt()
Expand Down

0 comments on commit b41dc03

Please sign in to comment.