55import sys
66import warnings
77
8- from _pytest .warning_types import PytestDeprecationWarning
8+ from _pytest .warning_types import PytestPendingDeprecationWarning
99import pytest
1010from pytest import ExitCode
1111from pytest import Pytester
@@ -161,7 +161,7 @@ def test_deprecated_call(self) -> None:
161161
162162 def test_deprecated_call_ret (self ) -> None :
163163 with pytest .warns (
164- PytestDeprecationWarning ,
164+ PytestPendingDeprecationWarning ,
165165 match = (
166166 wrap_escape (
167167 "The callable form of pytest.deprecated_call is deprecated.\n "
@@ -212,7 +212,7 @@ def f():
212212 msg = "No warnings of type (.*DeprecationWarning.*, .*PendingDeprecationWarning.*)"
213213 with pytest .raises (pytest .fail .Exception , match = msg ):
214214 if mode == "call" :
215- with pytest .warns (PytestDeprecationWarning ):
215+ with pytest .warns (PytestPendingDeprecationWarning ):
216216 pytest .deprecated_call (f )
217217 else :
218218 with pytest .deprecated_call ():
@@ -223,7 +223,7 @@ def f():
223223 )
224224 @pytest .mark .parametrize ("mode" , ["context_manager" , "call" ])
225225 @pytest .mark .parametrize ("call_f_first" , [True , False ])
226- @pytest .mark .filterwarnings ("ignore" )
226+ @pytest .mark .filterwarnings ("ignore:hi " )
227227 def test_deprecated_call_modes (self , warning_type , mode , call_f_first ) -> None :
228228 """Ensure deprecated_call() captures a deprecation warning as expected inside its
229229 block/function.
@@ -237,7 +237,8 @@ def f():
237237 if call_f_first :
238238 assert f () == 10
239239 if mode == "call" :
240- assert pytest .deprecated_call (f ) == 10
240+ with pytest .warns (PytestPendingDeprecationWarning ):
241+ assert pytest .deprecated_call (f ) == 10
241242 else :
242243 with pytest .deprecated_call ():
243244 assert f () == 10
@@ -258,7 +259,7 @@ def f():
258259
259260 with pytest .warns (warning ):
260261 with pytest .raises (pytest .fail .Exception ):
261- with pytest .warns (PytestDeprecationWarning ):
262+ with pytest .warns (PytestPendingDeprecationWarning ):
262263 pytest .deprecated_call (f )
263264 with pytest .raises (pytest .fail .Exception ):
264265 with pytest .deprecated_call ():
@@ -293,7 +294,7 @@ def test_several_messages(self) -> None:
293294
294295 def test_function (self ) -> None :
295296 with pytest .warns (
296- PytestDeprecationWarning ,
297+ PytestPendingDeprecationWarning ,
297298 match = (
298299 wrap_escape (
299300 "The callable form of pytest.warns is deprecated.\n "
@@ -452,16 +453,17 @@ def test_none_of_multiple_warns(self) -> None:
452453 warnings .warn ("bbbbbbbbbb" , UserWarning )
453454 warnings .warn ("cccccccccc" , UserWarning )
454455
455- @pytest .mark .filterwarnings ("ignore" )
456+ @pytest .mark .filterwarnings ("ignore:ohai " )
456457 def test_can_capture_previously_warned (self ) -> None :
457458 def f () -> int :
458459 warnings .warn (UserWarning ("ohai" ))
459460 return 10
460461
461462 assert f () == 10
462- assert pytest .warns (UserWarning , f ) == 10
463- assert pytest .warns (UserWarning , f ) == 10
464- assert pytest .warns (UserWarning , f ) != "10" # type: ignore[comparison-overlap]
463+ with pytest .warns (PytestPendingDeprecationWarning ):
464+ assert pytest .warns (UserWarning , f ) == 10
465+ assert pytest .warns (UserWarning , f ) == 10
466+ assert pytest .warns (UserWarning , f ) != "10" # type: ignore[comparison-overlap]
465467
466468 def test_warns_context_manager_with_kwargs (self ) -> None :
467469 with pytest .raises (TypeError ) as excinfo :
0 commit comments