Skip to content
Closed
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 @@ -197,6 +197,7 @@ Guido Wesdorp
Guoqiang Zhang
Hamza Mobeen
Harald Armin Massa
Harsh Kumar
Harshna
Henk-Jaap Wagenaar
Holger Kohr
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 ``hasattr`` call in ``_as_numpy_array`` that incorrectly used the string literal ``"obj"`` instead of the variable ``obj`` when checking for ``__array_interface__``, causing objects implementing only ``__array_interface__`` to not be recognized as numpy-like arrays by ``pytest.approx``.
2 changes: 1 addition & 1 deletion src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,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)
Comment on lines +909 to 910
return None
Loading