aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 56a42f055d0..dd5a781ed59 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -422,14 +422,20 @@ class ReferencesTestCase(TestBase):
self.assertEqual("".join(reversed(weakref.proxy(obj))), "cba")
def test_proxy_hash(self):
- cool_hash = 299_792_458
-
class MyObj:
def __hash__(self):
- return cool_hash
+ return 42
+
+ obj = MyObj()
+ with self.assertRaises(TypeError):
+ hash(weakref.proxy(obj))
+
+ class MyObj:
+ __hash__ = None
obj = MyObj()
- self.assertEqual(hash(weakref.proxy(obj)), cool_hash)
+ with self.assertRaises(TypeError):
+ hash(weakref.proxy(obj))
def test_getweakrefcount(self):
o = C()