Address all feedback, minus the empty sring v None nodeid which is being discussed

This commit is contained in:
Gleb Nikonorov 2020-05-25 11:18:24 -04:00
parent 088d400b2d
commit 125b663f20
3 changed files with 14 additions and 4 deletions

View File

@ -620,7 +620,12 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
"""
@hookspec(historic=True)
@hookspec(
historic=True,
warn_on_impl=DeprecationWarning(
"pytest_warning_captured is deprecated and will be removed soon"
),
)
def pytest_warning_captured(warning_message, when, item, location):
"""(**Deprecated**) Process a warning captured by the internal pytest warnings plugin.

View File

@ -411,9 +411,6 @@ class TerminalReporter:
self.write_line("INTERNALERROR> " + line)
return 1
def pytest_warning_captured(self, warning_message, item):
pass
def pytest_warning_recorded(self, warning_message, nodeid):
from _pytest.warnings import warning_record_to_str

View File

@ -111,6 +111,9 @@ def catch_warnings_for_item(config, ihook, when, item):
yield
for warning_message in log:
ihook.pytest_warning_captured.call_historic(
kwargs=dict(warning_message=warning_message, when=when, item=item)
)
ihook.pytest_warning_recorded.call_historic(
kwargs=dict(warning_message=warning_message, nodeid=nodeid, when=when)
)
@ -181,6 +184,11 @@ def _issue_warning_captured(warning, hook, stacklevel):
assert records is not None
frame = sys._getframe(stacklevel - 1)
location = frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name
hook.pytest_warning_captured.call_historic(
kwargs=dict(
warning_message=records[0], when="config", item=None, location=location
)
)
hook.pytest_warning_recorded.call_historic(
kwargs=dict(
warning_message=records[0], when="config", nodeid="", location=location