Skip to content

Commit ee91d09

Browse files
committed
doc: fix more broken Sphinx references
1 parent f76af42 commit ee91d09

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

doc/en/changelog.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ Features
13441344

13451345
This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
13461346

1347-
Internally, the old :class:`~pytest.Testdir` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
1347+
Internally, the old ``pytest.Testdir`` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
13481348

13491349

13501350
- :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
@@ -1592,7 +1592,7 @@ Improvements
15921592

15931593

15941594
- :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`.
1595-
These attributes are :class:`pathlib.Path` versions of the existing :attr:`rootdir <pytest.Config.rootdir>` and :attr:`inifile <pytest.Config.inifile>` attributes,
1595+
These attributes are :class:`pathlib.Path` versions of the existing ``rootdir`` and ``inifile`` attributes,
15961596
and should be preferred over them when possible.
15971597

15981598

@@ -2139,7 +2139,7 @@ Bug Fixes
21392139
parameter when Python is called with the ``-bb`` flag.
21402140

21412141

2142-
- :issue:`7143`: Fix :meth:`pytest.File.from_parent` so it forwards extra keyword arguments to the constructor.
2142+
- :issue:`7143`: Fix :meth:`pytest.File.from_parent <_pytest.nodes.Node.from_parent>` so it forwards extra keyword arguments to the constructor.
21432143

21442144

21452145
- :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
@@ -2458,7 +2458,7 @@ Bug Fixes
24582458
- :issue:`6597`: Fix node ids which contain a parametrized empty-string variable.
24592459

24602460

2461-
- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's :func:`testdir.runpytest <pytest.Testdir.runpytest>` etc.
2461+
- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's ``testdir.runpytest`` etc.
24622462

24632463

24642464
- :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger.

doc/en/funcarg_compare.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ There are several limitations and difficulties with this approach:
4444

4545
2. parametrizing the "db" resource is not straight forward:
4646
you need to apply a "parametrize" decorator or implement a
47-
:py:func:`~hookspec.pytest_generate_tests` hook
47+
:hook:`pytest_generate_tests` hook
4848
calling :py:func:`~pytest.Metafunc.parametrize` which
4949
performs parametrization at the places where the resource
5050
is used. Moreover, you need to modify the factory to use an
@@ -92,7 +92,7 @@ Direct parametrization of funcarg resource factories
9292

9393
Previously, funcarg factories could not directly cause parametrization.
9494
You needed to specify a ``@parametrize`` decorator on your test function
95-
or implement a ``pytest_generate_tests`` hook to perform
95+
or implement a :hook:`pytest_generate_tests` hook to perform
9696
parametrization, i.e. calling a test multiple times with different value
9797
sets. pytest-2.3 introduces a decorator for use on the factory itself:
9898

src/_pytest/config/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ def __init__(self) -> None:
449449
def parse_hookimpl_opts(
450450
self, plugin: _PluggyPlugin, name: str
451451
) -> Optional[HookimplOpts]:
452+
""":meta private:"""
452453
# pytest hooks are always prefixed with "pytest_",
453454
# so we avoid accessing possibly non-readable attributes
454455
# (see issue #1073).
@@ -472,6 +473,7 @@ def parse_hookimpl_opts(
472473
)
473474

474475
def parse_hookspec_opts(self, module_or_class, name: str) -> Optional[HookspecOpts]:
476+
""":meta private:"""
475477
opts = super().parse_hookspec_opts(module_or_class, name)
476478
if opts is None:
477479
method = getattr(module_or_class, name)

src/_pytest/hookspec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
@hookspec(historic=True)
5656
def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
5757
"""Called at plugin registration time to allow adding new hooks via a call to
58-
``pluginmanager.add_hookspecs(module_or_class, prefix)``.
58+
:func:`pluginmanager.add_hookspecs(module_or_class, prefix) <pytest.PytestPluginManager.add_hookspecs>`.
5959
6060
:param pytest.PytestPluginManager pluginmanager: The pytest plugin manager.
6161
@@ -858,8 +858,8 @@ def pytest_warning_recorded(
858858
"""Process a warning captured by the internal pytest warnings plugin.
859859
860860
:param warning_message:
861-
The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
862-
the same attributes as the parameters of :py:func:`warnings.showwarning`.
861+
The captured warning. This is the same object produced by :class:`warnings.catch_warnings`,
862+
and contains the same attributes as the parameters of :py:func:`warnings.showwarning`.
863863
864864
:param when:
865865
Indicates when the warning was captured. Possible values:
@@ -940,10 +940,10 @@ def pytest_exception_interact(
940940
interactively handled.
941941
942942
May be called during collection (see :hook:`pytest_make_collect_report`),
943-
in which case ``report`` is a :class:`CollectReport`.
943+
in which case ``report`` is a :class:`~pytest.CollectReport`.
944944
945945
May be called during runtest of an item (see :hook:`pytest_runtest_protocol`),
946-
in which case ``report`` is a :class:`TestReport`.
946+
in which case ``report`` is a :class:`~pytest.TestReport`.
947947
948948
This hook is not called if the exception that was raised is an internal
949949
exception like ``skip.Exception``.

src/_pytest/nodes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pathlib
23
import warnings
34
from functools import cached_property
45
from inspect import signature
@@ -176,8 +177,8 @@ class Node(metaclass=NodeMeta):
176177
# Implemented in the legacypath plugin.
177178
#: A ``LEGACY_PATH`` copy of the :attr:`path` attribute. Intended for usage
178179
#: for methods not migrated to ``pathlib.Path`` yet, such as
179-
#: :meth:`Item.reportinfo`. Will be deprecated in a future release, prefer
180-
#: using :attr:`path` instead.
180+
#: :meth:`Item.reportinfo <pytest.Item.reportinfo>`. Will be deprecated in
181+
#: a future release, prefer using :attr:`path` instead.
181182
fspath: LEGACY_PATH
182183

183184
# Use __slots__ to make attribute access faster.
@@ -228,7 +229,7 @@ def __init__(
228229
if path is None and fspath is None:
229230
path = getattr(parent, "path", None)
230231
#: Filesystem path where this node was collected from (can be None).
231-
self.path: Path = _imply_path(type(self), path, fspath=fspath)
232+
self.path: pathlib.Path = _imply_path(type(self), path, fspath=fspath)
232233

233234
# The explicit annotation is to avoid publicly exposing NodeKeywords.
234235
#: Keywords/markers collected from all scopes.

src/_pytest/python_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,23 +797,23 @@ def raises( # noqa: F811
797797
) -> Union["RaisesContext[E]", _pytest._code.ExceptionInfo[E]]:
798798
r"""Assert that a code block/function call raises an exception type, or one of its subclasses.
799799
800-
:param typing.Type[E] | typing.Tuple[typing.Type[E], ...] expected_exception:
800+
:param expected_exception:
801801
The expected exception type, or a tuple if one of multiple possible
802802
exception types are expected. Note that subclasses of the passed exceptions
803803
will also match.
804804
805-
:kwparam str | typing.Pattern[str] | None match:
805+
:kwparam str | re.Pattern[str] | None match:
806806
If specified, a string containing a regular expression,
807807
or a regular expression object, that is tested against the string
808-
representation of the exception and its `PEP-678 <https://peps.python.org/pep-0678/>` `__notes__`
808+
representation of the exception and its :pep:`678` `__notes__`
809809
using :func:`re.search`.
810810
811811
To match a literal string that may contain :ref:`special characters
812812
<re-syntax>`, the pattern can first be escaped with :func:`re.escape`.
813813
814-
(This is only used when :py:func:`pytest.raises` is used as a context manager,
814+
(This is only used when ``pytest.raises`` is used as a context manager,
815815
and passed through to the function otherwise.
816-
When using :py:func:`pytest.raises` as a function, you can use:
816+
When using ``pytest.raises`` as a function, you can use:
817817
``pytest.raises(Exc, func, match="passed on").match("my pattern")``.)
818818
819819
Use ``pytest.raises`` as a context manager, which will capture the exception of the given

0 commit comments

Comments
 (0)