I would like to have a list of all the tests that have failed to be used at the end of session.
Pytest lets you define a hook pyt
I wanted a concise report of failed tests and parametrized variations so went with pytest_terminal_summary
in conftest.py
:
def pytest_terminal_summary(terminalreporter, exitstatus, config):
terminalreporter.section('Failed tests')
failures = [report.nodeid.split('::')[-1]
for report in terminalreporter.stats.get('failed', [])]
terminalreporter.write('\n'.join(failures) + '\n')
If you inspect terminalreporter._session.items
, there's more information you can add to the report, this is just what I wanted.