Skip to content

Commit d167564

Browse files
authored
Merge pull request #11678 from pytest-dev/doc-nitpicks
doc: fix some broken Sphinx references
2 parents a536f49 + 9056db4 commit d167564

20 files changed

+78
-77
lines changed

changelog/9288.breaking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:func:`pytest.warns <warns>` now re-emits unmatched warnings when the context
1+
:func:`~pytest.warns` now re-emits unmatched warnings when the context
22
closes -- previously it would consume all warnings, hiding those that were not
33
matched by the function.
44

doc/en/backwards-compatibility.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ b) transitional: the old and new API don't conflict
2222

2323
We will only start the removal of deprecated functionality in major releases (e.g. if we deprecate something in 3.0 we will start to remove it in 4.0), and keep it around for at least two minor releases (e.g. if we deprecate something in 3.9 and 4.0 is the next release, we start to remove it in 5.0, not in 4.0).
2424

25-
A deprecated feature scheduled to be removed in major version X will use the warning class `PytestRemovedInXWarning` (a subclass of :class:`~pytest.PytestDeprecationwarning`).
25+
A deprecated feature scheduled to be removed in major version X will use the warning class `PytestRemovedInXWarning` (a subclass of :class:`~pytest.PytestDeprecationWarning`).
2626

2727
When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn `PytestRemovedInXWarning` (e.g. `PytestRemovedIn4Warning`) into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
2828

doc/en/changelog.rst

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

doc/en/deprecations.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ arguments they only pass on to the superclass.
177177
resolved in future versions as we slowly get rid of the :pypi:`py`
178178
dependency (see :issue:`9283` for a longer discussion).
179179

180-
Due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`
180+
Due to the ongoing migration of methods like :meth:`~pytest.Item.reportinfo`
181181
which still is expected to return a ``py.path.local`` object, nodes still have
182182
both ``fspath`` (``py.path.local``) and ``path`` (``pathlib.Path``) attributes,
183183
no matter what argument was used in the constructor. We expect to deprecate the
@@ -336,7 +336,7 @@ Diamond inheritance between :class:`pytest.Collector` and :class:`pytest.Item`
336336

337337
.. deprecated:: 7.0
338338

339-
Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` (e.g. :class:`pytest.File <File>`) now issues a warning.
339+
Defining a custom pytest node type which is both an :class:`~pytest.Item` and a :class:`~pytest.Collector` (e.g. :class:`~pytest.File`) now issues a warning.
340340
It was never sanely supported and triggers hard to debug errors.
341341

342342
Some plugins providing linting/code analysis have been using this as a hack.
@@ -348,8 +348,8 @@ Instead, a separate collector node should be used, which collects the item. See
348348

349349
.. _uncooperative-constructors-deprecated:
350350

351-
Constructors of custom :class:`pytest.Node` subclasses should take ``**kwargs``
352-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351+
Constructors of custom :class:`~_pytest.nodes.Node` subclasses should take ``**kwargs``
352+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
353353

354354
.. deprecated:: 7.0
355355

doc/en/example/parametrize.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Parametrizing tests
55
=================================================
66

7-
.. currentmodule:: _pytest.python
8-
97
``pytest`` allows to easily parametrize test functions.
108
For basic docs, see :ref:`parametrize-basics`.
119

@@ -185,7 +183,7 @@ A quick port of "testscenarios"
185183
Here is a quick port to run tests configured with :pypi:`testscenarios`,
186184
an add-on from Robert Collins for the standard unittest framework. We
187185
only have to work a bit to construct the correct arguments for pytest's
188-
:py:func:`Metafunc.parametrize`:
186+
:py:func:`Metafunc.parametrize <pytest.Metafunc.parametrize>`:
189187

190188
.. code-block:: python
191189

doc/en/explanation/fixtures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ A note about fixture cleanup
162162
----------------------------
163163

164164
pytest does not do any special processing for :data:`SIGTERM <signal.SIGTERM>` and
165-
:data:`SIGQUIT <signal.SIGQUIT>` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
165+
``SIGQUIT`` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
166166
by the Python runtime via :class:`KeyboardInterrupt`), so fixtures that manage external resources which are important
167167
to be cleared when the Python process is terminated (by those signals) might leak resources.
168168

doc/en/funcarg_compare.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ funcarg mechanism, see :ref:`historical funcargs and pytest.funcargs`.
1111
If you are new to pytest, then you can simply ignore this
1212
section and read the other sections.
1313

14-
.. currentmodule:: _pytest
15-
1614
Shortcomings of the previous ``pytest_funcarg__`` mechanism
1715
--------------------------------------------------------------
1816

doc/en/historical-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ More details can be found in the :pull:`original PR <3317>`.
112112
.. note::
113113

114114
in a future major release of pytest we will introduce class based markers,
115-
at which point markers will no longer be limited to instances of :py:class:`~_pytest.mark.Mark`.
115+
at which point markers will no longer be limited to instances of :py:class:`~pytest.Mark`.
116116

117117

118118
cache plugin integrated into the core

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,6 @@ warnings: a WarningsRecorder instance. To view the recorded warnings, you can
382382
iterate over this instance, call ``len`` on it to get the number of recorded
383383
warnings, or index into it to get a particular recorded warning.
384384

385-
.. currentmodule:: _pytest.warnings
386-
387385
Full API: :class:`~_pytest.recwarn.WarningsRecorder`.
388386

389387
.. _`warns use cases`:

doc/en/how-to/fixtures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ configured in multiple ways.
12711271
Extending the previous example, we can flag the fixture to create two
12721272
``smtp_connection`` fixture instances which will cause all tests using the fixture
12731273
to run twice. The fixture function gets access to each parameter
1274-
through the special :py:class:`request <FixtureRequest>` object:
1274+
through the special :py:class:`request <pytest.FixtureRequest>` object:
12751275

12761276
.. code-block:: python
12771277

doc/en/how-to/writing_hook_functions.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ The remaining hook functions will not be called in this case.
5959
hook wrappers: executing around other hooks
6060
-------------------------------------------------
6161

62-
.. currentmodule:: _pytest.core
63-
64-
65-
6662
pytest plugins can implement hook wrappers which wrap the execution
6763
of other hook implementations. A hook wrapper is a generator function
6864
which yields exactly once. When pytest invokes hooks it first executes
@@ -165,6 +161,7 @@ Here is the order of execution:
165161
It's possible to use ``tryfirst`` and ``trylast`` also on hook wrappers
166162
in which case it will influence the ordering of hook wrappers among each other.
167163

164+
.. _`declaringhooks`:
168165

169166
Declaring new hooks
170167
------------------------
@@ -174,13 +171,11 @@ Declaring new hooks
174171
This is a quick overview on how to add new hooks and how they work in general, but a more complete
175172
overview can be found in `the pluggy documentation <https://pluggy.readthedocs.io/en/latest/>`__.
176173

177-
.. currentmodule:: _pytest.hookspec
178-
179174
Plugins and ``conftest.py`` files may declare new hooks that can then be
180175
implemented by other plugins in order to alter behaviour or interact with
181176
the new plugin:
182177

183-
.. autofunction:: pytest_addhooks
178+
.. autofunction:: _pytest.hookspec.pytest_addhooks
184179
:noindex:
185180

186181
Hooks are usually declared as do-nothing functions that contain only

doc/en/reference/fixtures.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ Fixtures reference
1111
.. seealso:: :ref:`about-fixtures`
1212
.. seealso:: :ref:`how-to-fixtures`
1313

14-
15-
.. currentmodule:: _pytest.python
16-
1714
.. _`Dependency injection`: https://en.wikipedia.org/wiki/Dependency_injection
1815

1916

@@ -76,15 +73,13 @@ Built-in fixtures
7673
:class:`pathlib.Path` objects.
7774

7875
:fixture:`tmpdir`
79-
Provide a :class:`py.path.local` object to a temporary
76+
Provide a `py.path.local <https://py.readthedocs.io/en/latest/path.html>`_ object to a temporary
8077
directory which is unique to each test function;
8178
replaced by :fixture:`tmp_path`.
8279

83-
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
84-
8580
:fixture:`tmpdir_factory`
8681
Make session-scoped temporary directories and return
87-
:class:`py.path.local` objects;
82+
``py.path.local`` objects;
8883
replaced by :fixture:`tmp_path_factory`.
8984

9085

doc/en/reference/reference.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,30 @@ Hooks
612612

613613
**Tutorial**: :ref:`writing-plugins`
614614

615-
.. currentmodule:: _pytest.hookspec
616-
617615
Reference to all hooks which can be implemented by :ref:`conftest.py files <localplugin>` and :ref:`plugins <plugins>`.
618616

617+
@pytest.hookimpl
618+
~~~~~~~~~~~~~~~~
619+
620+
.. function:: pytest.hookimpl
621+
:decorator:
622+
623+
pytest's decorator for marking functions as hook implementations.
624+
625+
See :ref:`writinghooks` and :func:`pluggy.HookimplMarker`.
626+
627+
@pytest.hookspec
628+
~~~~~~~~~~~~~~~~
629+
630+
.. function:: pytest.hookspec
631+
:decorator:
632+
633+
pytest's decorator for marking functions as hook specifications.
634+
635+
See :ref:`declaringhooks` and :func:`pluggy.HookspecMarker`.
636+
637+
.. currentmodule:: _pytest.hookspec
638+
619639
Bootstrapping hooks
620640
~~~~~~~~~~~~~~~~~~~
621641

src/_pytest/capture.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def writeorg(self, data: str) -> None:
588588

589589
@final
590590
class CaptureResult(NamedTuple, Generic[AnyStr]):
591-
"""The result of :method:`CaptureFixture.readouterr`."""
591+
"""The result of :method:`caplog.readouterr() <pytest.CaptureFixture.readouterr>`."""
592592

593593
out: AnyStr
594594
err: AnyStr
@@ -598,7 +598,7 @@ class CaptureResult(NamedTuple, Generic[AnyStr]):
598598
class CaptureResult(
599599
collections.namedtuple("CaptureResult", ["out", "err"]), Generic[AnyStr]
600600
):
601-
"""The result of :method:`CaptureFixture.readouterr`."""
601+
"""The result of :method:`caplog.readouterr() <pytest.CaptureFixture.readouterr>`."""
602602

603603
__slots__ = ()
604604

src/_pytest/config/argparsing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def addoption(self, *opts: str, **attrs: Any) -> None:
9898
:param opts:
9999
Option names, can be short or long options.
100100
:param attrs:
101-
Same attributes as the argparse library's :py:func:`add_argument()
101+
Same attributes as the argparse library's :meth:`add_argument()
102102
<argparse.ArgumentParser.add_argument>` function accepts.
103103
104104
After command line parsing, options are available on the pytest config
@@ -400,7 +400,7 @@ def addoption(self, *opts: str, **attrs: Any) -> None:
400400
:param opts:
401401
Option names, can be short or long options.
402402
:param attrs:
403-
Same attributes as the argparse library's :py:func:`add_argument()
403+
Same attributes as the argparse library's :meth:`add_argument()
404404
<argparse.ArgumentParser.add_argument>` function accepts.
405405
"""
406406
conflict = set(opts).intersection(

src/_pytest/hookspec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def pytest_addoption(parser: "Parser", pluginmanager: "PytestPluginManager") ->
9696
<pytest.Parser.addini>`.
9797
9898
:param pytest.PytestPluginManager pluginmanager:
99-
The pytest plugin manager, which can be used to install :py:func:`hookspec`'s
100-
or :py:func:`hookimpl`'s and allow one plugin to call another plugin's hooks
99+
The pytest plugin manager, which can be used to install :py:func:`~pytest.hookspec`'s
100+
or :py:func:`~pytest.hookimpl`'s and allow one plugin to call another plugin's hooks
101101
to change how command line options are added.
102102
103103
Options can later be accessed through the

src/_pytest/legacypath.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def chdir(self) -> None:
8888
return self._pytester.chdir()
8989

9090
def finalize(self) -> None:
91-
"""See :meth:`Pytester._finalize`."""
9291
return self._pytester._finalize()
9392

9493
def makefile(self, ext, *args, **kwargs) -> LEGACY_PATH:
@@ -269,7 +268,7 @@ def testdir(pytester: Pytester) -> Testdir:
269268
@final
270269
@dataclasses.dataclass
271270
class TempdirFactory:
272-
"""Backward compatibility wrapper that implements :class:`py.path.local`
271+
"""Backward compatibility wrapper that implements ``py.path.local``
273272
for :class:`TempPathFactory`.
274273
275274
.. note::
@@ -288,11 +287,11 @@ def __init__(
288287
self._tmppath_factory = tmppath_factory
289288

290289
def mktemp(self, basename: str, numbered: bool = True) -> LEGACY_PATH:
291-
"""Same as :meth:`TempPathFactory.mktemp`, but returns a :class:`py.path.local` object."""
290+
"""Same as :meth:`TempPathFactory.mktemp`, but returns a ``py.path.local`` object."""
292291
return legacy_path(self._tmppath_factory.mktemp(basename, numbered).resolve())
293292

294293
def getbasetemp(self) -> LEGACY_PATH:
295-
"""Same as :meth:`TempPathFactory.getbasetemp`, but returns a :class:`py.path.local` object."""
294+
"""Same as :meth:`TempPathFactory.getbasetemp`, but returns a ``py.path.local`` object."""
296295
return legacy_path(self._tmppath_factory.getbasetemp().resolve())
297296

298297

src/_pytest/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def set_level(self, level: Union[int, str], logger: Optional[str] = None) -> Non
522522
The levels of the loggers changed by this function will be
523523
restored to their initial values at the end of the test.
524524
525-
Will enable the requested logging level if it was disabled via :meth:`logging.disable`.
525+
Will enable the requested logging level if it was disabled via :func:`logging.disable`.
526526
527527
:param level: The level.
528528
:param logger: The logger to update. If not given, the root logger.
@@ -546,7 +546,7 @@ def at_level(
546546
the end of the 'with' statement the level is restored to its original
547547
value.
548548
549-
Will enable the requested logging level if it was disabled via :meth:`logging.disable`.
549+
Will enable the requested logging level if it was disabled via :func:`logging.disable`.
550550
551551
:param level: The level.
552552
:param logger: The logger to update. If not given, the root logger.

src/_pytest/pytester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ def runitem(self, source: str) -> Any:
10441044
The calling test instance (class containing the test method) must
10451045
provide a ``.getrunner()`` method which should return a runner which
10461046
can run the test protocol for a single item, e.g.
1047-
:py:func:`_pytest.runner.runtestprotocol`.
1047+
``_pytest.runner.runtestprotocol``.
10481048
"""
10491049
# used from runner functional tests
10501050
item = self.getitem(source)
@@ -1395,7 +1395,7 @@ def run(
13951395
:param stdin:
13961396
Optional standard input.
13971397
1398-
- If it is :py:attr:`CLOSE_STDIN` (Default), then this method calls
1398+
- If it is ``CLOSE_STDIN`` (Default), then this method calls
13991399
:py:class:`subprocess.Popen` with ``stdin=subprocess.PIPE``, and
14001400
the standard input is closed immediately after the new command is
14011401
started.

src/_pytest/python_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,6 @@ def raises( # noqa: F811
825825
When using :py:func:`pytest.raises` as a function, you can use:
826826
``pytest.raises(Exc, func, match="passed on").match("my pattern")``.)
827827
828-
.. currentmodule:: _pytest._code
829-
830828
Use ``pytest.raises`` as a context manager, which will capture the exception of the given
831829
type, or any of its subclasses::
832830

0 commit comments

Comments
 (0)