MCPcopy Index your code
hub / github.com/python/cpython / test_proxy_matmul

Method test_proxy_matmul

Lib/test/test_weakref.py:359–372  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

357 self.assertEqual(p, 21)
358
359 def test_proxy_matmul(self):
360 class C:
361 def __matmul__(self, other):
362 return 1729
363 def __rmatmul__(self, other):
364 return -163
365 def __imatmul__(self, other):
366 return 561
367 o = C()
368 p = weakref.proxy(o)
369 self.assertEqual(p @ 5, 1729)
370 self.assertEqual(5 @ p, -163)
371 p @= 5
372 self.assertEqual(p, 561)
373
374 # The PyWeakref_* C API is documented as allowing either NULL or
375 # None as the value for the callback, where either means "no

Callers

nothing calls this directly

Calls 3

proxyMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected