Skip to content

Commit 33808d9

Browse files
Update test_weakref.py
1 parent bcdaaac commit 33808d9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lib/test/test_weakref.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@ def _assert_no_proxy_refcount_leak(self, make_class, do_op, op_name):
561561

562562
# verify
563563
self.assertIsNone(ref(), f"Leaked object in '{op_name}' operation")
564+
565+
def test_proxy_unref_unary_refcount(self):
566+
class C:
567+
def __neg__(self): return 0
568+
self._assert_no_proxy_refcount_leak(C,lambda p, d: operator.neg(d), "Unary")
564569

565570
def test_proxy_unref_binary_refcount(self):
566571
class C:
@@ -577,6 +582,10 @@ class C:
577582
def __eq__(self, o): return NotImplemented
578583
self._assert_no_proxy_refcount_leak(C, lambda p, d: p == d, "Rich Compare")
579584

585+
def test_proxy_unref_wrapmethod_refcount(self):
586+
class C:
587+
def __repr__(self): return "C()"
588+
self._assert_no_proxy_refcount_leak(C, lambda p, d: repr(d), "Wrap Method")
580589

581590
def test_getweakrefcount(self):
582591
o = C()

0 commit comments

Comments
 (0)