Skip to content

Commit afd53ed

Browse files
authored
Link mentioned functions instead of using literals (#8045)
1 parent 329e66c commit afd53ed

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

doc/en/assert.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Assertions about expected exceptions
7474
------------------------------------------
7575

7676
In order to write assertions about raised exceptions, you can use
77-
``pytest.raises`` as a context manager like this:
77+
:func:`pytest.raises` as a context manager like this:
7878

7979
.. code-block:: python
8080
@@ -123,7 +123,7 @@ The regexp parameter of the ``match`` method is matched with the ``re.search``
123123
function, so in the above example ``match='123'`` would have worked as
124124
well.
125125

126-
There's an alternate form of the ``pytest.raises`` function where you pass
126+
There's an alternate form of the :func:`pytest.raises` function where you pass
127127
a function that will be executed with the given ``*args`` and ``**kwargs`` and
128128
assert that the given exception is raised:
129129

@@ -144,8 +144,8 @@ specific way than just having any exception raised:
144144
def test_f():
145145
f()
146146
147-
Using ``pytest.raises`` is likely to be better for cases where you are testing
148-
exceptions your own code is deliberately raising, whereas using
147+
Using :func:`pytest.raises` is likely to be better for cases where you are
148+
testing exceptions your own code is deliberately raising, whereas using
149149
``@pytest.mark.xfail`` with a check function is probably better for something
150150
like documenting unfixed bugs (where the test describes what "should" happen)
151151
or bugs in dependencies.

doc/en/skipping.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ These two examples illustrate situations where you don't want to check for a con
259259
at the module level, which is when a condition would otherwise be evaluated for marks.
260260

261261
This will make ``test_function`` ``XFAIL``. Note that no other code is executed after
262-
the ``pytest.xfail`` call, differently from the marker. That's because it is implemented
262+
the :func:`pytest.xfail` call, differently from the marker. That's because it is implemented
263263
internally by raising a known exception.
264264

265265
**Reference**: :ref:`pytest.mark.xfail ref`
@@ -358,7 +358,7 @@ By specifying on the commandline:
358358
pytest --runxfail
359359
360360
you can force the running and reporting of an ``xfail`` marked test
361-
as if it weren't marked at all. This also causes ``pytest.xfail`` to produce no effect.
361+
as if it weren't marked at all. This also causes :func:`pytest.xfail` to produce no effect.
362362

363363
Examples
364364
~~~~~~~~

doc/en/warnings.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Asserting warnings with the warns function
265265

266266

267267

268-
You can check that code raises a particular warning using ``pytest.warns``,
268+
You can check that code raises a particular warning using func:`pytest.warns`,
269269
which works in a similar manner to :ref:`raises <assertraises>`:
270270

271271
.. code-block:: python
@@ -293,7 +293,7 @@ argument ``match`` to assert that the exception matches a text or regex::
293293
...
294294
Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted...
295295

296-
You can also call ``pytest.warns`` on a function or code string:
296+
You can also call func:`pytest.warns` on a function or code string:
297297

298298
.. code-block:: python
299299
@@ -328,10 +328,10 @@ Alternatively, you can examine raised warnings in detail using the
328328
Recording warnings
329329
------------------
330330

331-
You can record raised warnings either using ``pytest.warns`` or with
331+
You can record raised warnings either using func:`pytest.warns` or with
332332
the ``recwarn`` fixture.
333333

334-
To record with ``pytest.warns`` without asserting anything about the warnings,
334+
To record with func:`pytest.warns` without asserting anything about the warnings,
335335
pass ``None`` as the expected warning type:
336336

337337
.. code-block:: python
@@ -360,7 +360,7 @@ The ``recwarn`` fixture will record warnings for the whole function:
360360
assert w.filename
361361
assert w.lineno
362362
363-
Both ``recwarn`` and ``pytest.warns`` return the same interface for recorded
363+
Both ``recwarn`` and func:`pytest.warns` return the same interface for recorded
364364
warnings: a WarningsRecorder instance. To view the recorded warnings, you can
365365
iterate over this instance, call ``len`` on it to get the number of recorded
366366
warnings, or index into it to get a particular recorded warning.
@@ -387,7 +387,7 @@ are met.
387387
pytest.fail("Expected a warning!")
388388
389389
If no warnings are issued when calling ``f``, then ``not record`` will
390-
evaluate to ``True``. You can then call ``pytest.fail`` with a
390+
evaluate to ``True``. You can then call :func:`pytest.fail` with a
391391
custom error message.
392392

393393
.. _internal-warnings:

src/_pytest/recwarn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def warns(
115115
one for each warning raised.
116116
117117
This function can be used as a context manager, or any of the other ways
118-
``pytest.raises`` can be used::
118+
:func:`pytest.raises` can be used::
119119
120120
>>> import pytest
121121
>>> with pytest.warns(RuntimeWarning):

0 commit comments

Comments
 (0)