diff --git a/changelog/8337.doc.rst b/changelog/8337.doc.rst new file mode 100644 index 00000000000..f2483a6b481 --- /dev/null +++ b/changelog/8337.doc.rst @@ -0,0 +1 @@ +Recommend `numpy.testing `__ module on :func:`pytest.approx` documentation. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 946d15b3122..e1ee057a420 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -654,6 +654,14 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase: special case that you explicitly specify an absolute tolerance but not a relative tolerance, only the absolute tolerance is considered. + .. note:: + + ``approx`` can handle numpy arrays, but we recommend the + specialised test helpers in `numpy.testing`__ if you need + support for comparisons, NaNs, or ULP-based tolerances. + + __ https://numpy.org/doc/stable/reference/routines.testing.html + .. warning:: .. versionchanged:: 3.2