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 docs for Item.add_report_section in the docs #2567

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,21 @@ def __init__(self, name, parent=None, config=None, session=None):
self._report_sections = []

def add_report_section(self, when, key, content):
"""
Adds a new report section, similar to what's done internally to add stdout and
stderr captured output::

item.add_report_section("call", "stdout", "report section contents")

:param str when:
One of the possible capture states, ``"setup"``, ``"call"``, ``"teardown"``.
:param str key:
Name of the section, can be customized at will. Pytest uses ``"stdout"`` and
``"stderr"`` internally.

:param str content:
The full contents as a string.
"""
if content:
self._report_sections.append((when, key, content))

Expand Down