diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py index 2c6d8ba5162..b5f51eccf50 100644 --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -269,7 +269,7 @@ def pytest_report_header(config, startdir): def pytest_report_teststatus(report): """ return result-category, shortletter and verbose word for reporting.""" -def pytest_terminal_summary(terminalreporter): +def pytest_terminal_summary(terminalreporter, exitstatus): """ add additional section in terminal summary reporting. """ diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 863e69ce80b..fdbe4ec36d0 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -361,7 +361,8 @@ def pytest_sessionfinish(self, exitstatus): EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED) if exitstatus in summary_exit_codes: - self.config.hook.pytest_terminal_summary(terminalreporter=self) + self.config.hook.pytest_terminal_summary(terminalreporter=self, + exitstatus=exitstatus) self.summary_errors() self.summary_failures() self.summary_warnings() diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 84c5bc4ac49..1307a924fbf 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -787,15 +787,17 @@ def test_error_fixture(setup_error_fixture): def test_terminal_summary(testdir): testdir.makeconftest(""" - def pytest_terminal_summary(terminalreporter): + def pytest_terminal_summary(terminalreporter, exitstatus): w = terminalreporter w.section("hello") w.line("world") + w.line("exitstatus: {}".format(exitstatus)) """) result = testdir.runpytest() result.stdout.fnmatch_lines(""" *==== hello ====* world + exitstatus: 5 """)