summaryrefslogtreecommitdiff
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.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 563507fee3..56a42f055d 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -411,6 +411,26 @@ class ReferencesTestCase(TestBase):
# can be killed in the middle of the call
"blech" in p
+ def test_proxy_reversed(self):
+ class MyObj:
+ def __len__(self):
+ return 3
+ def __reversed__(self):
+ return iter('cba')
+
+ obj = MyObj()
+ 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
+
+ obj = MyObj()
+ self.assertEqual(hash(weakref.proxy(obj)), cool_hash)
+
def test_getweakrefcount(self):
o = C()
ref1 = weakref.ref(o)