doc: fix more broken Sphinx references

This commit is contained in:
Ran Benita 2023-12-07 10:30:17 +02:00
parent f76af423b0
commit ee91d095f6
6 changed files with 22 additions and 19 deletions

View File

@ -1344,7 +1344,7 @@ Features
This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future. This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
Internally, the old :class:`~pytest.Testdir` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface. Internally, the old ``pytest.Testdir`` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
- :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary. - :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
@ -1592,7 +1592,7 @@ Improvements
- :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`. - :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`.
These attributes are :class:`pathlib.Path` versions of the existing :attr:`rootdir <pytest.Config.rootdir>` and :attr:`inifile <pytest.Config.inifile>` attributes, These attributes are :class:`pathlib.Path` versions of the existing ``rootdir`` and ``inifile`` attributes,
and should be preferred over them when possible. and should be preferred over them when possible.
@ -2139,7 +2139,7 @@ Bug Fixes
parameter when Python is called with the ``-bb`` flag. parameter when Python is called with the ``-bb`` flag.
- :issue:`7143`: Fix :meth:`pytest.File.from_parent` so it forwards extra keyword arguments to the constructor. - :issue:`7143`: Fix :meth:`pytest.File.from_parent <_pytest.nodes.Node.from_parent>` so it forwards extra keyword arguments to the constructor.
- :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures. - :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
@ -2458,7 +2458,7 @@ Bug Fixes
- :issue:`6597`: Fix node ids which contain a parametrized empty-string variable. - :issue:`6597`: Fix node ids which contain a parametrized empty-string variable.
- :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. - :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.
- :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger. - :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger.

View File

@ -44,7 +44,7 @@ There are several limitations and difficulties with this approach:
2. parametrizing the "db" resource is not straight forward: 2. parametrizing the "db" resource is not straight forward:
you need to apply a "parametrize" decorator or implement a you need to apply a "parametrize" decorator or implement a
:py:func:`~hookspec.pytest_generate_tests` hook :hook:`pytest_generate_tests` hook
calling :py:func:`~pytest.Metafunc.parametrize` which calling :py:func:`~pytest.Metafunc.parametrize` which
performs parametrization at the places where the resource performs parametrization at the places where the resource
is used. Moreover, you need to modify the factory to use an is used. Moreover, you need to modify the factory to use an
@ -92,7 +92,7 @@ Direct parametrization of funcarg resource factories
Previously, funcarg factories could not directly cause parametrization. Previously, funcarg factories could not directly cause parametrization.
You needed to specify a ``@parametrize`` decorator on your test function You needed to specify a ``@parametrize`` decorator on your test function
or implement a ``pytest_generate_tests`` hook to perform or implement a :hook:`pytest_generate_tests` hook to perform
parametrization, i.e. calling a test multiple times with different value parametrization, i.e. calling a test multiple times with different value
sets. pytest-2.3 introduces a decorator for use on the factory itself: sets. pytest-2.3 introduces a decorator for use on the factory itself:

View File

@ -449,6 +449,7 @@ class PytestPluginManager(PluginManager):
def parse_hookimpl_opts( def parse_hookimpl_opts(
self, plugin: _PluggyPlugin, name: str self, plugin: _PluggyPlugin, name: str
) -> Optional[HookimplOpts]: ) -> Optional[HookimplOpts]:
""":meta private:"""
# pytest hooks are always prefixed with "pytest_", # pytest hooks are always prefixed with "pytest_",
# so we avoid accessing possibly non-readable attributes # so we avoid accessing possibly non-readable attributes
# (see issue #1073). # (see issue #1073).
@ -472,6 +473,7 @@ class PytestPluginManager(PluginManager):
) )
def parse_hookspec_opts(self, module_or_class, name: str) -> Optional[HookspecOpts]: def parse_hookspec_opts(self, module_or_class, name: str) -> Optional[HookspecOpts]:
""":meta private:"""
opts = super().parse_hookspec_opts(module_or_class, name) opts = super().parse_hookspec_opts(module_or_class, name)
if opts is None: if opts is None:
method = getattr(module_or_class, name) method = getattr(module_or_class, name)

View File

@ -55,7 +55,7 @@ hookspec = HookspecMarker("pytest")
@hookspec(historic=True) @hookspec(historic=True)
def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None: def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
"""Called at plugin registration time to allow adding new hooks via a call to """Called at plugin registration time to allow adding new hooks via a call to
``pluginmanager.add_hookspecs(module_or_class, prefix)``. :func:`pluginmanager.add_hookspecs(module_or_class, prefix) <pytest.PytestPluginManager.add_hookspecs>`.
:param pytest.PytestPluginManager pluginmanager: The pytest plugin manager. :param pytest.PytestPluginManager pluginmanager: The pytest plugin manager.
@ -858,8 +858,8 @@ def pytest_warning_recorded(
"""Process a warning captured by the internal pytest warnings plugin. """Process a warning captured by the internal pytest warnings plugin.
:param warning_message: :param warning_message:
The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains The captured warning. This is the same object produced by :class:`warnings.catch_warnings`,
the same attributes as the parameters of :py:func:`warnings.showwarning`. and contains the same attributes as the parameters of :py:func:`warnings.showwarning`.
:param when: :param when:
Indicates when the warning was captured. Possible values: Indicates when the warning was captured. Possible values:
@ -940,10 +940,10 @@ def pytest_exception_interact(
interactively handled. interactively handled.
May be called during collection (see :hook:`pytest_make_collect_report`), May be called during collection (see :hook:`pytest_make_collect_report`),
in which case ``report`` is a :class:`CollectReport`. in which case ``report`` is a :class:`~pytest.CollectReport`.
May be called during runtest of an item (see :hook:`pytest_runtest_protocol`), May be called during runtest of an item (see :hook:`pytest_runtest_protocol`),
in which case ``report`` is a :class:`TestReport`. in which case ``report`` is a :class:`~pytest.TestReport`.
This hook is not called if the exception that was raised is an internal This hook is not called if the exception that was raised is an internal
exception like ``skip.Exception``. exception like ``skip.Exception``.

View File

@ -1,4 +1,5 @@
import os import os
import pathlib
import warnings import warnings
from functools import cached_property from functools import cached_property
from inspect import signature from inspect import signature
@ -176,8 +177,8 @@ class Node(metaclass=NodeMeta):
# Implemented in the legacypath plugin. # Implemented in the legacypath plugin.
#: A ``LEGACY_PATH`` copy of the :attr:`path` attribute. Intended for usage #: A ``LEGACY_PATH`` copy of the :attr:`path` attribute. Intended for usage
#: for methods not migrated to ``pathlib.Path`` yet, such as #: for methods not migrated to ``pathlib.Path`` yet, such as
#: :meth:`Item.reportinfo`. Will be deprecated in a future release, prefer #: :meth:`Item.reportinfo <pytest.Item.reportinfo>`. Will be deprecated in
#: using :attr:`path` instead. #: a future release, prefer using :attr:`path` instead.
fspath: LEGACY_PATH fspath: LEGACY_PATH
# Use __slots__ to make attribute access faster. # Use __slots__ to make attribute access faster.
@ -228,7 +229,7 @@ class Node(metaclass=NodeMeta):
if path is None and fspath is None: if path is None and fspath is None:
path = getattr(parent, "path", None) path = getattr(parent, "path", None)
#: Filesystem path where this node was collected from (can be None). #: Filesystem path where this node was collected from (can be None).
self.path: Path = _imply_path(type(self), path, fspath=fspath) self.path: pathlib.Path = _imply_path(type(self), path, fspath=fspath)
# The explicit annotation is to avoid publicly exposing NodeKeywords. # The explicit annotation is to avoid publicly exposing NodeKeywords.
#: Keywords/markers collected from all scopes. #: Keywords/markers collected from all scopes.

View File

@ -797,23 +797,23 @@ def raises( # noqa: F811
) -> Union["RaisesContext[E]", _pytest._code.ExceptionInfo[E]]: ) -> Union["RaisesContext[E]", _pytest._code.ExceptionInfo[E]]:
r"""Assert that a code block/function call raises an exception type, or one of its subclasses. r"""Assert that a code block/function call raises an exception type, or one of its subclasses.
:param typing.Type[E] | typing.Tuple[typing.Type[E], ...] expected_exception: :param expected_exception:
The expected exception type, or a tuple if one of multiple possible The expected exception type, or a tuple if one of multiple possible
exception types are expected. Note that subclasses of the passed exceptions exception types are expected. Note that subclasses of the passed exceptions
will also match. will also match.
:kwparam str | typing.Pattern[str] | None match: :kwparam str | re.Pattern[str] | None match:
If specified, a string containing a regular expression, If specified, a string containing a regular expression,
or a regular expression object, that is tested against the string or a regular expression object, that is tested against the string
representation of the exception and its `PEP-678 <https://peps.python.org/pep-0678/>` `__notes__` representation of the exception and its :pep:`678` `__notes__`
using :func:`re.search`. using :func:`re.search`.
To match a literal string that may contain :ref:`special characters To match a literal string that may contain :ref:`special characters
<re-syntax>`, the pattern can first be escaped with :func:`re.escape`. <re-syntax>`, the pattern can first be escaped with :func:`re.escape`.
(This is only used when :py:func:`pytest.raises` is used as a context manager, (This is only used when ``pytest.raises`` is used as a context manager,
and passed through to the function otherwise. and passed through to the function otherwise.
When using :py:func:`pytest.raises` as a function, you can use: When using ``pytest.raises`` as a function, you can use:
``pytest.raises(Exc, func, match="passed on").match("my pattern")``.) ``pytest.raises(Exc, func, match="passed on").match("my pattern")``.)
Use ``pytest.raises`` as a context manager, which will capture the exception of the given Use ``pytest.raises`` as a context manager, which will capture the exception of the given