Skip to content

Commit

Permalink
BUG: Fix test_void_dtype_equality_failures for Python 3.
Browse files Browse the repository at this point in the history
The NotArray test class needs to define a `__ne__` method, otherwise the
inherited Python 3 method will call `__eq__`, resulting in two rather
than one DeprecationWarning.
  • Loading branch information
charris committed Jun 13, 2015
1 parent c65a751 commit df148e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions numpy/core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def assert_deprecated(self, function, num=1, ignore_others=False,
function(*args, **kwargs)
except (Exception if function_fails else tuple()):
pass

# just in case, clear the registry
num_found = 0
for warning in self.log:
Expand Down Expand Up @@ -447,6 +448,10 @@ class NotArray(object):
def __array__(self):
raise TypeError

# Needed so Python 3 does not raise DeprecationWarning twice.
def __ne__(self, other):
return NotImplemented

self.assert_deprecated(lambda: np.arange(2) == NotArray())
self.assert_deprecated(lambda: np.arange(2) != NotArray())

Expand Down

0 comments on commit df148e1

Please sign in to comment.