Skip to content

Commit 088d400

Browse files
committed
rename pytest_warning_record -> pytest_warning_recorded
1 parent b02d087 commit 088d400

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

doc/en/reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ Session related reporting hooks:
711711
.. autofunction:: pytest_fixture_setup
712712
.. autofunction:: pytest_fixture_post_finalizer
713713
.. autofunction:: pytest_warning_captured
714-
.. autofunction:: pytest_warning_record
714+
.. autofunction:: pytest_warning_recorded
715715

716716
Central hook for reporting about test execution:
717717

src/_pytest/hookspec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def pytest_warning_captured(warning_message, when, item, location):
625625
"""(**Deprecated**) Process a warning captured by the internal pytest warnings plugin.
626626
627627
This hook is considered deprecated and will be removed in a future pytest version.
628-
Use :func:`pytest_warning_record` instead.
628+
Use :func:`pytest_warning_recorded` instead.
629629
630630
:param warnings.WarningMessage warning_message:
631631
The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
@@ -648,7 +648,7 @@ def pytest_warning_captured(warning_message, when, item, location):
648648

649649

650650
@hookspec(historic=True)
651-
def pytest_warning_record(warning_message, when, nodeid, location):
651+
def pytest_warning_recorded(warning_message, when, nodeid, location):
652652
"""
653653
Process a warning captured by the internal pytest warnings plugin.
654654

src/_pytest/terminal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def pytest_report_teststatus(report: TestReport) -> Tuple[str, str, str]:
227227
@attr.s
228228
class WarningReport:
229229
"""
230-
Simple structure to hold warnings information captured by ``pytest_warning_record``.
230+
Simple structure to hold warnings information captured by ``pytest_warning_recorded``.
231231
232232
:ivar str message: user friendly message about the warning
233233
:ivar str|None nodeid: node id that generated the warning (see ``get_location``).
@@ -414,7 +414,7 @@ def pytest_internalerror(self, excrepr):
414414
def pytest_warning_captured(self, warning_message, item):
415415
pass
416416

417-
def pytest_warning_record(self, warning_message, nodeid):
417+
def pytest_warning_recorded(self, warning_message, nodeid):
418418
from _pytest.warnings import warning_record_to_str
419419

420420
fslocation = warning_message.filename, warning_message.lineno

src/_pytest/warnings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def catch_warnings_for_item(config, ihook, when, item):
8181
8282
``item`` can be None if we are not in the context of an item execution.
8383
84-
Each warning captured triggers the ``pytest_warning_record`` hook.
84+
Each warning captured triggers the ``pytest_warning_recorded`` hook.
8585
"""
8686
cmdline_filters = config.getoption("pythonwarnings") or []
8787
inifilters = config.getini("filterwarnings")
@@ -111,7 +111,7 @@ def catch_warnings_for_item(config, ihook, when, item):
111111
yield
112112

113113
for warning_message in log:
114-
ihook.pytest_warning_record.call_historic(
114+
ihook.pytest_warning_recorded.call_historic(
115115
kwargs=dict(warning_message=warning_message, nodeid=nodeid, when=when)
116116
)
117117

@@ -167,7 +167,7 @@ def pytest_sessionfinish(session):
167167
def _issue_warning_captured(warning, hook, stacklevel):
168168
"""
169169
This function should be used instead of calling ``warnings.warn`` directly when we are in the "configure" stage:
170-
at this point the actual options might not have been set, so we manually trigger the pytest_warning_record
170+
at this point the actual options might not have been set, so we manually trigger the pytest_warning_recorded
171171
hook so we can display these warnings in the terminal. This is a hack until we can sort out #2891.
172172
173173
:param warning: the warning instance.
@@ -181,7 +181,7 @@ def _issue_warning_captured(warning, hook, stacklevel):
181181
assert records is not None
182182
frame = sys._getframe(stacklevel - 1)
183183
location = frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name
184-
hook.pytest_warning_record.call_historic(
184+
hook.pytest_warning_recorded.call_historic(
185185
kwargs=dict(
186186
warning_message=records[0], when="config", nodeid="", location=location
187187
)

testing/test_warnings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def test_func(fix):
268268
collected = []
269269

270270
class WarningCollector:
271-
def pytest_warning_record(self, warning_message, when, nodeid):
271+
def pytest_warning_recorded(self, warning_message, when, nodeid):
272272
collected.append((str(warning_message.message), when, nodeid))
273273

274274
result = testdir.runpytest(plugins=[WarningCollector()])
@@ -648,7 +648,7 @@ class CapturedWarnings:
648648
captured = []
649649

650650
@classmethod
651-
def pytest_warning_record(cls, warning_message, when, nodeid, location):
651+
def pytest_warning_recorded(cls, warning_message, when, nodeid, location):
652652
cls.captured.append((warning_message, location))
653653

654654
testdir.plugins = [CapturedWarnings()]

0 commit comments

Comments
 (0)