diff --git a/AUTHORS b/AUTHORS index f3cf1b0facb..b72d0136484 100644 --- a/AUTHORS +++ b/AUTHORS @@ -21,6 +21,7 @@ Alex Lambson Alexander Johnson Alexander King Alexei Kozlenok +algojogacor Alice Purcell Allan Feldman Aly Sivji diff --git a/changelog/14456.bugfix.rst b/changelog/14456.bugfix.rst new file mode 100644 index 00000000000..ccd9ca20a8f --- /dev/null +++ b/changelog/14456.bugfix.rst @@ -0,0 +1 @@ +Fixed :func:`pytest.approx` not recognizing types with ``__array_interface__`` as numpy-like arrays. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index cc2a2b7126a..f22a0f5016d 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -925,6 +925,6 @@ def _as_numpy_array(obj: object) -> ndarray | None: return None elif isinstance(obj, np.ndarray): return obj - elif hasattr(obj, "__array__") or hasattr("obj", "__array_interface__"): + elif hasattr(obj, "__array__") or hasattr(obj, "__array_interface__"): return np.asarray(obj) return None