Skip to content

Commit 8062743

Browse files
authored
Change deprecated_call to handle FutureWarning (#11448)
Fixes #11447
1 parent 8b7f94f commit 8062743

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

changelog/11447.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`pytest.deprecated_call` now also considers warnings of type :class:`FutureWarning`.

src/_pytest/recwarn.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def deprecated_call( # noqa: F811
5656
def deprecated_call( # noqa: F811
5757
func: Optional[Callable[..., Any]] = None, *args: Any, **kwargs: Any
5858
) -> Union["WarningsRecorder", Any]:
59-
"""Assert that code produces a ``DeprecationWarning`` or ``PendingDeprecationWarning``.
59+
"""Assert that code produces a ``DeprecationWarning`` or ``PendingDeprecationWarning`` or ``FutureWarning``.
6060
6161
This function can be used as a context manager::
6262
@@ -82,7 +82,9 @@ def deprecated_call( # noqa: F811
8282
__tracebackhide__ = True
8383
if func is not None:
8484
args = (func,) + args
85-
return warns((DeprecationWarning, PendingDeprecationWarning), *args, **kwargs)
85+
return warns(
86+
(DeprecationWarning, PendingDeprecationWarning, FutureWarning), *args, **kwargs
87+
)
8688

8789

8890
@overload

testing/test_recwarn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def f():
192192
f()
193193

194194
@pytest.mark.parametrize(
195-
"warning_type", [PendingDeprecationWarning, DeprecationWarning]
195+
"warning_type", [PendingDeprecationWarning, DeprecationWarning, FutureWarning]
196196
)
197197
@pytest.mark.parametrize("mode", ["context_manager", "call"])
198198
@pytest.mark.parametrize("call_f_first", [True, False])
@@ -221,7 +221,6 @@ def test_deprecated_call_specificity(self) -> None:
221221
UserWarning,
222222
SyntaxWarning,
223223
RuntimeWarning,
224-
FutureWarning,
225224
ImportWarning,
226225
UnicodeWarning,
227226
]

0 commit comments

Comments
 (0)