Fix DeprecationWarning in tests (#4345)
Define __hash__() in test_functools and test_itertools to fix the
following warning:
DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index b3372ea..2847573 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -609,6 +609,8 @@
return self.value > other.value
def __eq__(self, other):
return self.value == other.value
+ def __hash__(self):
+ return hash(self.value)
self.assertTrue(A(1) != A(2))
self.assertFalse(A(1) != A(1))
@@ -620,6 +622,8 @@
return self.value > other.value
def __eq__(self, other):
return self.value == other.value
+ def __hash__(self):
+ return hash(self.value)
self.assertTrue(A(1) != A(2))
self.assertFalse(A(1) != A(1))
@@ -633,6 +637,8 @@
return self.value == other.value
def __ne__(self, other):
raise RuntimeError(self, other)
+ def __hash__(self):
+ return hash(self.value)
with self.assertRaises(RuntimeError):
A(1) != A(2)
with self.assertRaises(RuntimeError):
@@ -648,6 +654,8 @@
return self.value == other.value
def __ne__(self, other):
raise RuntimeError(self, other)
+ def __hash__(self):
+ return hash(self.value)
with self.assertRaises(RuntimeError):
A(1) != A(2)
with self.assertRaises(RuntimeError):