@@ -173,8 +173,6 @@ DeprecationWarning and PendingDeprecationWarning
173173------------------------------------------------
174174
175175
176-
177-
178176By default pytest will display ``DeprecationWarning `` and ``PendingDeprecationWarning `` warnings from
179177user code and third-party libraries, as recommended by `PEP-0565 <https://www.python.org/dev/peps/pep-0565 >`_.
180178This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed.
@@ -230,27 +228,8 @@ that a certain function call triggers a ``DeprecationWarning`` or
230228 This test will fail if ``myfunction `` does not issue a deprecation warning
231229when called with a ``17 `` argument.
232230
233- By default, ``DeprecationWarning `` and ``PendingDeprecationWarning `` will not be
234- caught when using :func: `pytest.warns ` or :ref: `recwarn <recwarn >` because
235- the default Python warnings filters hide
236- them. If you wish to record them in your own code, use
237- ``warnings.simplefilter('always') ``:
238-
239- .. code-block :: python
240-
241- import warnings
242- import pytest
243-
244-
245- def test_deprecation (recwarn ):
246- warnings.simplefilter(" always" )
247- myfunction(17 )
248- assert len (recwarn) == 1
249- assert recwarn.pop(DeprecationWarning )
250231
251232
252- The :ref: `recwarn <recwarn >` fixture automatically ensures to reset the warnings
253- filter at the end of the test, so no global state is leaked.
254233
255234.. _`asserting warnings` :
256235
@@ -317,9 +296,9 @@ additional information:
317296 Alternatively, you can examine raised warnings in detail using the
318297:ref: `recwarn <recwarn >` fixture (see below).
319298
320- .. note ::
321- `` DeprecationWarning `` and `` PendingDeprecationWarning `` are treated
322- differently; see :ref: ` ensuring_function_triggers ` .
299+
300+ The :ref: ` recwarn < recwarn >` fixture automatically ensures to reset the warnings
301+ filter at the end of the test, so no global state is leaked .
323302
324303.. _`recording warnings` :
325304
0 commit comments