Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Alex Lambson
Alexander Johnson
Alexander King
Alexei Kozlenok
algojogacor
Alice Purcell
Allan Feldman
Aly Sivji
Expand Down
1 change: 1 addition & 0 deletions changelog/14456.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug in :func:`pytest.approx` where ``_as_numpy_array`` incorrectly used a string literal ``"obj"`` instead of the variable ``obj`` when checking for ``__array_interface__``, causing objects implementing only ``__array_interface__`` (without ``__array__``) to not be recognized as numpy-like arrays.
2 changes: 1 addition & 1 deletion src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading