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

Function pytest_warning_captured

src/_pytest/hookspec.py:781–812  ·  view source on GitHub ↗

(**Deprecated**) Process a warning captured by the internal pytest warnings plugin. .. deprecated:: 6.0 This hook is considered deprecated and will be removed in a future pytest version. Use :func:`pytest_warning_recorded` instead. :param warnings.WarningMessage warning_message:

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

Source from the content-addressed store, hash-verified

779
780@hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK)
781def pytest_warning_captured(
782 warning_message: "warnings.WarningMessage",
783 when: "Literal['config', 'collect', 'runtest']",
784 item: Optional["Item"],
785 location: Optional[Tuple[str, int, str]],
786) -> None:
787 """(**Deprecated**) Process a warning captured by the internal pytest warnings plugin.
788
789 .. deprecated:: 6.0
790
791 This hook is considered deprecated and will be removed in a future pytest version.
792 Use :func:`pytest_warning_recorded` instead.
793
794 :param warnings.WarningMessage warning_message:
795 The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
796 the same attributes as the parameters of :py:func:`warnings.showwarning`.
797
798 :param str when:
799 Indicates when the warning was captured. Possible values:
800
801 * ``"config"``: during pytest configuration/initialization stage.
802 * ``"collect"``: during test collection.
803 * ``"runtest"``: during test execution.
804
805 :param pytest.Item|None item:
806 The item being executed if ``when`` is ``"runtest"``, otherwise ``None``.
807
808 :param tuple location:
809 When available, holds information about the execution context of the captured
810 warning (filename, linenumber, function). ``function`` evaluates to <module>
811 when the execution context is at the module level.
812 """
813
814
815@hookspec(historic=True)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected