@@ -173,8 +173,6 @@ DeprecationWarning and PendingDeprecationWarning
173
173
------------------------------------------------
174
174
175
175
176
-
177
-
178
176
By default pytest will display ``DeprecationWarning `` and ``PendingDeprecationWarning `` warnings from
179
177
user code and third-party libraries, as recommended by `PEP-0565 <https://www.python.org/dev/peps/pep-0565 >`_.
180
178
This 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
230
228
This test will fail if ``myfunction `` does not issue a deprecation warning
231
229
when called with a ``17 `` argument.
232
230
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 )
250
231
251
232
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.
254
233
255
234
.. _`asserting warnings` :
256
235
@@ -317,9 +296,9 @@ additional information:
317
296
Alternatively, you can examine raised warnings in detail using the
318
297
:ref: `recwarn <recwarn >` fixture (see below).
319
298
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 .
323
302
324
303
.. _`recording warnings` :
325
304
0 commit comments