Skip to content

Commit 125b663

Browse files
committed
Address all feedback, minus the empty sring v None nodeid which is being discussed
1 parent 088d400 commit 125b663

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/_pytest/hookspec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,12 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
620620
"""
621621

622622

623-
@hookspec(historic=True)
623+
@hookspec(
624+
historic=True,
625+
warn_on_impl=DeprecationWarning(
626+
"pytest_warning_captured is deprecated and will be removed soon"
627+
),
628+
)
624629
def pytest_warning_captured(warning_message, when, item, location):
625630
"""(**Deprecated**) Process a warning captured by the internal pytest warnings plugin.
626631

src/_pytest/terminal.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,6 @@ def pytest_internalerror(self, excrepr):
411411
self.write_line("INTERNALERROR> " + line)
412412
return 1
413413

414-
def pytest_warning_captured(self, warning_message, item):
415-
pass
416-
417414
def pytest_warning_recorded(self, warning_message, nodeid):
418415
from _pytest.warnings import warning_record_to_str
419416

src/_pytest/warnings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def catch_warnings_for_item(config, ihook, when, item):
111111
yield
112112

113113
for warning_message in log:
114+
ihook.pytest_warning_captured.call_historic(
115+
kwargs=dict(warning_message=warning_message, when=when, item=item)
116+
)
114117
ihook.pytest_warning_recorded.call_historic(
115118
kwargs=dict(warning_message=warning_message, nodeid=nodeid, when=when)
116119
)
@@ -181,6 +184,11 @@ def _issue_warning_captured(warning, hook, stacklevel):
181184
assert records is not None
182185
frame = sys._getframe(stacklevel - 1)
183186
location = frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name
187+
hook.pytest_warning_captured.call_historic(
188+
kwargs=dict(
189+
warning_message=records[0], when="config", item=None, location=location
190+
)
191+
)
184192
hook.pytest_warning_recorded.call_historic(
185193
kwargs=dict(
186194
warning_message=records[0], when="config", nodeid="", location=location

0 commit comments

Comments
 (0)