Fix API links in 'How to capture warnings' documentation page (#8792)

This commit is contained in:
James Bourbeau 2021-06-23 14:34:48 -05:00 committed by GitHub
parent f573b56bb6
commit 942789bace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -144,6 +144,7 @@ Iwan Briquemont
Jaap Broekhuizen Jaap Broekhuizen
Jakob van Santen Jakob van Santen
Jakub Mitoraj Jakub Mitoraj
James Bourbeau
Jan Balster Jan Balster
Janne Vanhala Janne Vanhala
Jason R. Coombs Jason R. Coombs

View File

@ -244,7 +244,7 @@ Asserting warnings with the warns function
You can check that code raises a particular warning using func:`pytest.warns`, You can check that code raises a particular warning using :func:`pytest.warns`,
which works in a similar manner to :ref:`raises <assertraises>`: which works in a similar manner to :ref:`raises <assertraises>`:
.. code-block:: python .. code-block:: python
@ -272,7 +272,7 @@ argument ``match`` to assert that the exception matches a text or regex::
... ...
Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted... Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted...
You can also call func:`pytest.warns` on a function or code string: You can also call :func:`pytest.warns` on a function or code string:
.. code-block:: python .. code-block:: python
@ -307,10 +307,10 @@ filter at the end of the test, so no global state is leaked.
Recording warnings Recording warnings
------------------ ------------------
You can record raised warnings either using func:`pytest.warns` or with You can record raised warnings either using :func:`pytest.warns` or with
the ``recwarn`` fixture. the ``recwarn`` fixture.
To record with func:`pytest.warns` without asserting anything about the warnings, To record with :func:`pytest.warns` without asserting anything about the warnings,
pass no arguments as the expected warning type and it will default to a generic Warning: pass no arguments as the expected warning type and it will default to a generic Warning:
.. code-block:: python .. code-block:: python
@ -339,7 +339,7 @@ The ``recwarn`` fixture will record warnings for the whole function:
assert w.filename assert w.filename
assert w.lineno assert w.lineno
Both ``recwarn`` and func:`pytest.warns` return the same interface for recorded Both ``recwarn`` and :func:`pytest.warns` return the same interface for recorded
warnings: a WarningsRecorder instance. To view the recorded warnings, you can warnings: a WarningsRecorder instance. To view the recorded warnings, you can
iterate over this instance, call ``len`` on it to get the number of recorded iterate over this instance, call ``len`` on it to get the number of recorded
warnings, or index into it to get a particular recorded warning. warnings, or index into it to get a particular recorded warning.