Merge pull request #1809 from blueyed/exitstatus-with-pytest_terminal_summary
Pass exitstatus to pytest_terminal_summary hook
This commit is contained in:
commit
d3b855104c
|
@ -269,7 +269,7 @@ def pytest_report_header(config, startdir):
|
||||||
def pytest_report_teststatus(report):
|
def pytest_report_teststatus(report):
|
||||||
""" return result-category, shortletter and verbose word for reporting."""
|
""" 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. """
|
""" add additional section in terminal summary reporting. """
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -361,7 +361,8 @@ class TerminalReporter:
|
||||||
EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR,
|
EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR,
|
||||||
EXIT_NOTESTSCOLLECTED)
|
EXIT_NOTESTSCOLLECTED)
|
||||||
if exitstatus in summary_exit_codes:
|
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_errors()
|
||||||
self.summary_failures()
|
self.summary_failures()
|
||||||
self.summary_warnings()
|
self.summary_warnings()
|
||||||
|
|
|
@ -787,15 +787,17 @@ def test_tbstyle_native_setup_error(testdir):
|
||||||
|
|
||||||
def test_terminal_summary(testdir):
|
def test_terminal_summary(testdir):
|
||||||
testdir.makeconftest("""
|
testdir.makeconftest("""
|
||||||
def pytest_terminal_summary(terminalreporter):
|
def pytest_terminal_summary(terminalreporter, exitstatus):
|
||||||
w = terminalreporter
|
w = terminalreporter
|
||||||
w.section("hello")
|
w.section("hello")
|
||||||
w.line("world")
|
w.line("world")
|
||||||
|
w.line("exitstatus: {0}".format(exitstatus))
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.stdout.fnmatch_lines("""
|
result.stdout.fnmatch_lines("""
|
||||||
*==== hello ====*
|
*==== hello ====*
|
||||||
world
|
world
|
||||||
|
exitstatus: 5
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue