_pytest.warnings module¶
-
_setoption(wmod, arg)[source]¶ Copy of the warning._setoption function but does not escape arguments.
-
with
catch_warnings_for_item(config, ihook, when, item)[source]¶ Context manager that catches warnings generated in the contained execution block.
itemcan be None if we are not in the context of an item execution.Each warning captured triggers the
pytest_warning_capturedhook.
-
for ... in
pytest_collection(session: _pytest.main.Session) → Generator[None, None, None][source]¶
-
_issue_warning_captured(warning, hook, stacklevel)[source]¶ This function should be used instead of calling
warnings.warndirectly when we are in the “configure” stage: at this point the actual options might not have been set, so we manually trigger the pytest_warning_captured hook so we can display these warnings in the terminal. This is a hack until we can sort out #2891.- Parameters
warning – the warning instance.
hook – the hook caller
stacklevel – stacklevel forwarded to warnings.warn