Skip to content

Commit 8900e3b

Browse files
authored
Merge pull request #9041 from hoefling/doc/stdlib-crossrefs
2 parents 4274af1 + d1aea7d commit 8900e3b

File tree

13 files changed

+33
-46
lines changed

13 files changed

+33
-46
lines changed

doc/en/changelog.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ Improvements
411411
and should be preferred over them when possible.
412412

413413

414-
- `#7780 <https://github.com/pytest-dev/pytest/issues/7780>`_: Public classes which are not designed to be inherited from are now marked `@final <https://docs.python.org/3/library/typing.html#typing.final>`_.
414+
- `#7780 <https://github.com/pytest-dev/pytest/issues/7780>`_: Public classes which are not designed to be inherited from are now marked :func:`@final <typing.final>`.
415415
Code which inherits from these classes will trigger a type-checking (e.g. mypy) error, but will still work in runtime.
416416
Currently the ``final`` designation does not appear in the API Reference but hopefully will in the future.
417417

@@ -785,7 +785,7 @@ Features
785785
- `#6906 <https://github.com/pytest-dev/pytest/issues/6906>`_: Added `--code-highlight` command line option to enable/disable code highlighting in terminal output.
786786

787787

788-
- `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`_: New ``--import-mode=importlib`` option that uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules.
788+
- `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`_: New ``--import-mode=importlib`` option that uses :mod:`importlib` to import test modules.
789789

790790
Traditionally pytest used ``__import__`` while changing ``sys.path`` to import test modules (which
791791
also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules
@@ -2032,7 +2032,7 @@ Features
20322032
This hook is still **experimental** so use it with caution.
20332033

20342034

2035-
- `#5440 <https://github.com/pytest-dev/pytest/issues/5440>`_: The `faulthandler <https://docs.python.org/3/library/faulthandler.html>`__ standard library
2035+
- `#5440 <https://github.com/pytest-dev/pytest/issues/5440>`_: The :mod:`faulthandler` standard library
20362036
module is now enabled by default to help users diagnose crashes in C modules.
20372037

20382038
This functionality was provided by integrating the external
@@ -3130,7 +3130,7 @@ Features
31303130
will not issue the warning.
31313131

31323132

3133-
- `#3632 <https://github.com/pytest-dev/pytest/issues/3632>`_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <https://www.attrs.org/en/stable/>`__ or `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (Python 3.7+, `backported to 3.6 <https://pypi.org/project/dataclasses>`__).
3133+
- `#3632 <https://github.com/pytest-dev/pytest/issues/3632>`_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <https://www.attrs.org/en/stable/>`__ or :mod:`dataclasses` (Python 3.7+, `backported to 3.6 <https://pypi.org/project/dataclasses>`__).
31343134

31353135

31363136
- `#4278 <https://github.com/pytest-dev/pytest/issues/4278>`_: ``CACHEDIR.TAG`` files are now created inside cache directories.

doc/en/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348

349349
# Example configuration for intersphinx: refer to the Python standard library.
350350
intersphinx_mapping = {
351-
"pluggy": ("https://pluggy.readthedocs.io/en/latest", None),
351+
"pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
352352
"python": ("https://docs.python.org/3", None),
353353
}
354354

doc/en/explanation/goodpractices.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Good Integration Practices
77
Install package with pip
88
-------------------------------------------------
99

10-
For development, we recommend you use venv_ for virtual environments and
10+
For development, we recommend you use :mod:`venv` for virtual environments and
1111
pip_ for installing your application and any dependencies,
1212
as well as the ``pytest`` package itself.
1313
This ensures your code and dependencies are isolated from your system Python installation.
@@ -248,5 +248,3 @@ dependencies and then executing a pre-configured test command with
248248
options. It will run tests against the installed package and not
249249
against your source code checkout, helping to detect packaging
250250
glitches.
251-
252-
.. _`venv`: https://docs.python.org/3/library/venv.html

doc/en/explanation/pythonpath.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Import modes
1111
pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution.
1212

1313
Importing files in Python (at least until recently) is a non-trivial processes, often requiring
14-
changing `sys.path <https://docs.python.org/3/library/sys.html#sys.path>`__. Some aspects of the
14+
changing :data:`sys.path`. Some aspects of the
1515
import process can be controlled through the ``--import-mode`` command-line flag, which can assume
1616
these values:
1717

1818
* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
19-
of :py:data:`sys.path` if not already there, and then imported with the `__import__ <https://docs.python.org/3/library/functions.html#__import__>`__ builtin.
19+
of :py:data:`sys.path` if not already there, and then imported with the :func:`__import__ <__import__>` builtin.
2020

2121
This requires test module names to be unique when the test directory tree is not arranged in
2222
packages, because the modules will put in :py:data:`sys.modules` after importing.
@@ -43,7 +43,7 @@ these values:
4343
Same as ``prepend``, requires test module names to be unique when the test directory tree is
4444
not arranged in packages, because the modules will put in :py:data:`sys.modules` after importing.
4545

46-
* ``importlib``: new in pytest-6.0, this mode uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
46+
* ``importlib``: new in pytest-6.0, this mode uses :mod:`importlib` to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
4747

4848
For this reason this doesn't require test module names to be unique, but also makes test
4949
modules non-importable by each other.

doc/en/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The ``[100%]`` refers to the overall progress of running all test cases. After i
7171

7272
.. note::
7373

74-
You can use the ``assert`` statement to verify test expectations. pytest’s `Advanced assertion introspection <https://docs.python.org/reference/simple_stmts.html>`_ will intelligently report intermediate values of the assert expression so you can avoid the many names `of JUnit legacy methods <https://docs.python.org/library/how-to/unittest.html>`_.
74+
You can use the ``assert`` statement to verify test expectations. pytest’s :ref:`Advanced assertion introspection <python:assert>` will intelligently report intermediate values of the assert expression so you can avoid the many names :ref:`of JUnit legacy methods <testcase-objects>`.
7575

7676
Run multiple tests
7777
----------------------------------------------------------

doc/en/how-to/capture-warnings.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ When a warning matches more than one option in the list, the action for the last
9898
is performed.
9999

100100
Both ``-W`` command-line option and ``filterwarnings`` ini option are based on Python's own
101-
`-W option`_ and `warnings.simplefilter`_, so please refer to those sections in the Python
101+
:option:`-W option <python:-W>` and :func:`warnings.simplefilter`, so please refer to those sections in the Python
102102
documentation for other examples and advanced usage.
103103

104104
.. _`filterwarnings`:
@@ -143,8 +143,6 @@ decorator or to all tests in a module by setting the :globalvar:`pytestmark` var
143143
*Credits go to Florian Schulze for the reference implementation in the* `pytest-warnings`_
144144
*plugin.*
145145

146-
.. _`-W option`: https://docs.python.org/3/using/cmdline.html#cmdoption-w
147-
.. _warnings.simplefilter: https://docs.python.org/3/library/how-to/capture-warnings.html#warnings.simplefilter
148146
.. _`pytest-warnings`: https://github.com/fschulze/pytest-warnings
149147

150148
Disabling warnings summary
@@ -196,12 +194,12 @@ the regular expression ``".*U.*mode is deprecated"``.
196194
.. note::
197195

198196
If warnings are configured at the interpreter level, using
199-
the `PYTHONWARNINGS <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS>`_ environment variable or the
197+
the :envvar:`python:PYTHONWARNINGS` environment variable or the
200198
``-W`` command-line option, pytest will not configure any filters by default.
201199

202200
Also pytest doesn't follow ``PEP-0506`` suggestion of resetting all warning filters because
203201
it might break test suites that configure warning filters themselves
204-
by calling ``warnings.simplefilter`` (see issue `#2430 <https://github.com/pytest-dev/pytest/issues/2430>`_
202+
by calling :func:`warnings.simplefilter` (see issue `#2430 <https://github.com/pytest-dev/pytest/issues/2430>`_
205203
for an example of that).
206204

207205

doc/en/how-to/doctest.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ How to run doctests
44
=========================================================
55

66
By default, all files matching the ``test*.txt`` pattern will
7-
be run through the python standard ``doctest`` module. You
7+
be run through the python standard :mod:`doctest` module. You
88
can change the pattern by issuing:
99

1010
.. code-block:: bash
@@ -95,7 +95,7 @@ that will be used for those doctest files using the
9595
Using 'doctest' options
9696
-----------------------
9797

98-
Python's standard ``doctest`` module provides some `options <https://docs.python.org/3/library/how-to/doctest.html#option-flags>`__
98+
Python's standard :mod:`doctest` module provides some :ref:`options <python:option-flags-and-directives>`
9999
to configure the strictness of doctest tests. In pytest, you can enable those flags using the
100100
configuration file.
101101

@@ -252,7 +252,7 @@ For the same reasons one might want to skip normal tests, it is also possible to
252252
tests inside doctests.
253253

254254
To skip a single check inside a doctest you can use the standard
255-
`doctest.SKIP <https://docs.python.org/3/library/how-to/doctest.html#doctest.SKIP>`__ directive:
255+
:data:`doctest.SKIP` directive:
256256

257257
.. code-block:: python
258258

doc/en/how-to/failures.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ To stop the testing process after the first (N) failures:
1818
1919
.. _pdb-option:
2020

21-
Using PDB_ (Python Debugger) with pytest
22-
----------------------------------------------------------
21+
Using :doc:`python:library/pdb` with pytest
22+
-------------------------------------------
2323

24-
Dropping to PDB_ (Python Debugger) on failures
25-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
Dropping to :doc:`pdb <python:library/pdb>` on failures
25+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2626

27-
.. _PDB: https://docs.python.org/library/pdb.html
28-
29-
Python comes with a builtin Python debugger called PDB_. ``pytest``
30-
allows one to drop into the PDB_ prompt via a command line option:
27+
Python comes with a builtin Python debugger called :doc:`pdb <python:library/pdb>`. ``pytest``
28+
allows one to drop into the :doc:`pdb <python:library/pdb>` prompt via a command line option:
3129

3230
.. code-block:: bash
3331
@@ -57,10 +55,10 @@ for example::
5755

5856
.. _trace-option:
5957

60-
Dropping to PDB_ at the start of a test
61-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
Dropping to :doc:`pdb <python:library/pdb>` at the start of a test
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6260

63-
``pytest`` allows one to drop into the PDB_ prompt immediately at the start of each test via a command line option:
61+
``pytest`` allows one to drop into the :doc:`pdb <python:library/pdb>` prompt immediately at the start of each test via a command line option:
6462

6563
.. code-block:: bash
6664
@@ -106,7 +104,7 @@ Fault Handler
106104

107105
.. versionadded:: 5.0
108106

109-
The `faulthandler <https://docs.python.org/3/library/faulthandler.html>`__ standard module
107+
The :mod:`faulthandler` standard module
110108
can be used to dump Python tracebacks on a segfault or after a timeout.
111109

112110
The module is automatically enabled for pytest runs, unless the ``-p no:faulthandler`` is given

doc/en/how-to/fixtures.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,9 +1577,9 @@ Use fixtures in classes and modules with ``usefixtures``
15771577
Sometimes test functions do not directly need access to a fixture object.
15781578
For example, tests may require to operate with an empty directory as the
15791579
current working directory but otherwise do not care for the concrete
1580-
directory. Here is how you can use the standard `tempfile
1581-
<https://docs.python.org/library/tempfile.html>`_ and pytest fixtures to
1582-
achieve it. We separate the creation of the fixture into a conftest.py
1580+
directory. Here is how you can use the standard :mod:`tempfile`
1581+
and pytest fixtures to
1582+
achieve it. We separate the creation of the fixture into a :file:`conftest.py`
15831583
file:
15841584

15851585
.. code-block:: python

doc/en/how-to/unittest.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ Almost all ``unittest`` features are supported:
2828
* ``setUpModule/tearDownModule``;
2929

3030
.. _`load_tests protocol`: https://docs.python.org/3/library/how-to/unittest.html#load-tests-protocol
31-
.. _`subtests`: https://docs.python.org/3/library/how-to/unittest.html#distinguishing-test-iterations-using-subtests
3231

3332
Up to this point pytest does not have support for the following features:
3433

3534
* `load_tests protocol`_;
36-
* `subtests`_;
35+
* :ref:`subtests <python:subtests>`;
3736

3837
Benefits out of the box
3938
-----------------------

0 commit comments

Comments
 (0)