MCPcopy Create free account
hub / github.com/pytest-dev/pytest / pytest_warning_recorded

Function pytest_warning_recorded

src/_pytest/hookspec.py:816–844  ·  view source on GitHub ↗

Process a warning captured by the internal pytest warnings plugin. :param warnings.WarningMessage warning_message: The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains the same attributes as the parameters of :py:func:`warnin

(
    warning_message: "warnings.WarningMessage",
    when: "Literal['config', 'collect', 'runtest']",
    nodeid: str,
    location: Optional[Tuple[str, int, str]],
)

Source from the content-addressed store, hash-verified

814
815@hookspec(historic=True)
816def pytest_warning_recorded(
817 warning_message: "warnings.WarningMessage",
818 when: "Literal['config', 'collect', 'runtest']",
819 nodeid: str,
820 location: Optional[Tuple[str, int, str]],
821) -> None:
822 """Process a warning captured by the internal pytest warnings plugin.
823
824 :param warnings.WarningMessage warning_message:
825 The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
826 the same attributes as the parameters of :py:func:`warnings.showwarning`.
827
828 :param str when:
829 Indicates when the warning was captured. Possible values:
830
831 * ``"config"``: during pytest configuration/initialization stage.
832 * ``"collect"``: during test collection.
833 * ``"runtest"``: during test execution.
834
835 :param str nodeid:
836 Full id of the item.
837
838 :param tuple|None location:
839 When available, holds information about the execution context of the captured
840 warning (filename, linenumber, function). ``function`` evaluates to <module>
841 when the execution context is at the module level.
842
843 .. versionadded:: 6.0
844 """
845
846
847# -------------------------------------------------------------------------

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected