summaryrefslogtreecommitdiff
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2019-04-26 15:56:15 +0900
committerGitHub <noreply@github.com>2019-04-26 15:56:15 +0900
commit7abb6c05afd02c17c7a941b64db5756b161b3cf7 (patch)
treee8fd0e63830dd923246db8aa57bed76b526c915f /Lib/test/test_weakref.py
parent3cde440f20a9db75fb2c4e65e8e4d04a53216a2d (diff)
downloadcpython-git-7abb6c05afd02c17c7a941b64db5756b161b3cf7.tar.gz
bpo-36669: add matmul support to weakref.proxy (GH-12932)
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 50a46f817f..6f15c03ac5 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -285,6 +285,21 @@ class ReferencesTestCase(TestBase):
p //= 5
self.assertEqual(p, 21)
+ def test_proxy_matmul(self):
+ class C:
+ def __matmul__(self, other):
+ return 1729
+ def __rmatmul__(self, other):
+ return -163
+ def __imatmul__(self, other):
+ return 561
+ o = C()
+ p = weakref.proxy(o)
+ self.assertEqual(p @ 5, 1729)
+ self.assertEqual(5 @ p, -163)
+ p @= 5
+ self.assertEqual(p, 561)
+
# The PyWeakref_* C API is documented as allowing either NULL or
# None as the value for the callback, where either means "no
# callback". The "no callback" ref and proxy objects are supposed