diff --git a/AUTHORS b/AUTHORS index 620ed218886..af895ed1855 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 bab70aa4a8c..1ff35e94fcf 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -814,6 +814,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