@@ -195,7 +195,7 @@ user code and third-party libraries, as recommended by :pep:`565`.
195
195
This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed.
196
196
197
197
However, in the specific case where users capture any type of warnings in their test, either with
198
- :func: `pytest.warns `, :func: `pytest.deprecated_call ` or using the :ref : `recwarn < recwarn > ` fixture,
198
+ :func: `pytest.warns `, :func: `pytest.deprecated_call ` or using the :fixture : `recwarn ` fixture,
199
199
no warning will be displayed at all.
200
200
201
201
Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over
@@ -332,10 +332,10 @@ additional information:
332
332
assert record[0 ].message.args[0 ] == " another warning"
333
333
334
334
Alternatively, you can examine raised warnings in detail using the
335
- :ref : `recwarn < recwarn > ` fixture (see below).
335
+ :fixture : `recwarn ` fixture (see :ref: ` below < recwarn >` ).
336
336
337
337
338
- The :ref : `recwarn < recwarn > ` fixture automatically ensures to reset the warnings
338
+ The :fixture : `recwarn ` fixture automatically ensures to reset the warnings
339
339
filter at the end of the test, so no global state is leaked.
340
340
341
341
.. _`recording warnings` :
@@ -345,8 +345,8 @@ filter at the end of the test, so no global state is leaked.
345
345
Recording warnings
346
346
------------------
347
347
348
- You can record raised warnings either using :func: `pytest.warns ` or with
349
- the `` recwarn ` ` fixture.
348
+ You can record raised warnings either using the :func: `pytest.warns ` context manager or with
349
+ the :fixture: ` recwarn ` fixture.
350
350
351
351
To record with :func: `pytest.warns ` without asserting anything about the warnings,
352
352
pass no arguments as the expected warning type and it will default to a generic Warning:
@@ -361,7 +361,7 @@ pass no arguments as the expected warning type and it will default to a generic
361
361
assert str (record[0 ].message) == " user"
362
362
assert str (record[1 ].message) == " runtime"
363
363
364
- The `` recwarn ` ` fixture will record warnings for the whole function:
364
+ The :fixture: ` recwarn ` fixture will record warnings for the whole function:
365
365
366
366
.. code-block :: python
367
367
@@ -377,12 +377,11 @@ The ``recwarn`` fixture will record warnings for the whole function:
377
377
assert w.filename
378
378
assert w.lineno
379
379
380
- Both `` recwarn `` and :func: `pytest.warns ` return the same interface for recorded
381
- warnings: a WarningsRecorder instance. To view the recorded warnings, you can
380
+ Both the :fixture: ` recwarn ` fixture and the :func: `pytest.warns ` context manager return the same interface for recorded
381
+ warnings: a :class: ` ~_pytest.recwarn. WarningsRecorder` instance. To view the recorded warnings, you can
382
382
iterate over this instance, call ``len `` on it to get the number of recorded
383
383
warnings, or index into it to get a particular recorded warning.
384
384
385
- Full API: :class: `~_pytest.recwarn.WarningsRecorder `.
386
385
387
386
.. _`warns use cases` :
388
387
0 commit comments