Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_weakref.py @ 20903:bfcc2ed9caba legacy-trunk
Add a regression test for SF bug #478536: If a value cannot be weakly
referenced, WeakKeyDictionary.has_key() should return 0 instead of raising
TypeError.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 06 Nov 2001 16:38:34 +0000 |
| parents | 4f7befec35b0 |
| children | 3d68e3110e1f |
line wrap: on
line diff
--- a/Lib/test/test_weakref.py Tue Nov 06 16:36:53 2001 +0000 +++ b/Lib/test/test_weakref.py Tue Nov 06 16:38:34 2001 +0000 @@ -272,7 +272,7 @@ def test_weak_keys(self): # # This exercises d.copy(), d.items(), d[] = v, d[], del d[], - # len(d). + # len(d), d.has_key(). # dict, objects = self.make_weak_keyed_dict() for o in objects: @@ -294,6 +294,10 @@ del objects, o self.assert_(len(dict) == 0, "deleting the keys did not clear the dictionary") + o = Object(42) + dict[o] = "What is the meaning of the universe?" + self.assert_(dict.has_key(o)) + self.assert_(not dict.has_key(34)) def test_weak_keyed_iters(self): dict, objects = self.make_weak_keyed_dict()
