Revert to having just "runtest" as "when" parameter of the pytest_warning_captured hook
This commit is contained in:
parent
5a52acaa92
commit
2e0a7cf78d
|
@ -559,13 +559,10 @@ def pytest_warning_captured(warning_message, when, item):
|
|||
|
||||
* ``"config"``: during pytest configuration/initialization stage.
|
||||
* ``"collect"``: during test collection.
|
||||
* ``"setup"``: during test setup.
|
||||
* ``"call"``: during test call.
|
||||
* ``"teardown"``: during test teardown.
|
||||
* ``"runtest"``: during test execution.
|
||||
|
||||
:param pytest.Item|None item:
|
||||
The item being executed if ``when`` is ``"setup"``, ``"call"`` or ``"teardown"``, otherwise
|
||||
``None``.
|
||||
The item being executed if ``when`` is ``"runtest"``, otherwise ``None``.
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
@ -130,25 +130,9 @@ def warning_record_to_str(warning_message):
|
|||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_setup(item):
|
||||
def pytest_runtest_protocol(item):
|
||||
with catch_warnings_for_item(
|
||||
config=item.config, ihook=item.ihook, when="setup", item=item
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_call(item):
|
||||
with catch_warnings_for_item(
|
||||
config=item.config, ihook=item.ihook, when="call", item=item
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_teardown(item):
|
||||
with catch_warnings_for_item(
|
||||
config=item.config, ihook=item.ihook, when="teardown", item=item
|
||||
config=item.config, ihook=item.ihook, when="runtest", item=item
|
||||
):
|
||||
yield
|
||||
|
||||
|
|
|
@ -341,9 +341,9 @@ def test_warning_captured_hook(testdir):
|
|||
expected = [
|
||||
("config warning", "config", ""),
|
||||
("collect warning", "collect", ""),
|
||||
("setup warning", "setup", "test_func"),
|
||||
("call warning", "call", "test_func"),
|
||||
("teardown warning", "teardown", "test_func"),
|
||||
("setup warning", "runtest", "test_func"),
|
||||
("call warning", "runtest", "test_func"),
|
||||
("teardown warning", "runtest", "test_func"),
|
||||
]
|
||||
assert collected == expected
|
||||
|
||||
|
|
Loading…
Reference in New Issue