Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recursion in pytest.approx() with arrays in numpy<1.13 #3761

Merged
merged 2 commits into from
Aug 2, 2018
Merged
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 changelog/3748.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix infinite recursion in ``pytest.approx`` with arrays in ``numpy<1.13``.
4 changes: 3 additions & 1 deletion src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def __eq__(self, actual):
the pre-specified tolerance.
"""
if _is_numpy_array(actual):
return all(a == self for a in actual.flat)
# Call ``__eq__()`` manually to prevent infinite-recursion with
# numpy<1.13. See #3748.
return all(self.__eq__(a) for a in actual.flat)

# Short-circuit exact equality.
if actual == self.expected:
Expand Down