From 7abb6c05afd02c17c7a941b64db5756b161b3cf7 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 26 Apr 2019 15:56:15 +0900 Subject: bpo-36669: add matmul support to weakref.proxy (GH-12932) --- Lib/test/test_weakref.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Lib/test') 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 -- cgit v1.2.1